Answer
a)
a(x) =
x for $ 0 \leq x \leq 1$
2-x for $ 1 \lt x \leq 2$
b)
b(x) =
2 for $0\leq x \lt 1$
0 for $1\leq x \lt 2$
2 for $2\leq x \lt 3$
0 for $3\leq x \leq 4$
Work Step by Step
a) The first part of the graph is a straight line through (0,0) and (1,1), so its formula is y = x. This part of the graphs starts at x = 0 (included) and ends at x = 1 (included), so the domain is $ 0 \leq x \leq 1$.
The second part of the graph is a straight line through (1,1) and (2,0), so its formula is y = 2 - x. This part of the graph starts at x = 1 (not included) and ends at x = 2 (included), so the domain is $ 1 \lt x \leq 2$.
So a(x) =
x for $ 0 \leq x \leq 1$
2-x for $ 1 \lt x \leq 2$
b) The function starts with a horizontal line with the formula y = 2. This part of the graph starts at x =0 (included) and ends at x = 1 (not included) and starts again at x = 2 (included) and ends at x = 3 (not included). So its domain is $0\leq x \lt 1$ and $2\leq x \lt 3$
The second part of the function is a horizontal line with the formula y = 0. This part of the graph starts at x =1 (included) and ends at x = 2 (not included) and starts again at x = 3 (included) and ends at x = 4 (included). So its domain is $1\leq x \lt 2$ and $3\leq x \leq 4$
So b(x) =
2 for $0\leq x \lt 1$
0 for $1\leq x \lt 2$
2 for $2\leq x \lt 3$
0 for $3\leq x \leq 4$