A Motzkin path of length n is a sequence of points (0, 0) = P0, P1, ..., Pn = (n, 0) where Pi - Pi-1 ∈ {(1, 1), (1, -1), (1, 0)} and the y-coordinate of Pi is nonnegative for all i. Below are all the Motzkin paths from (0, 0) to (4, 0).
(a) Find a recursive construction for the set of all Motzkin paths.
(b) Use the construction you found in the previous part to find the generating function for Motzkin paths of any length.