I am learning this right now...
I find it helpful to think of it this way:
building from the end of the string,
___1 = g(n-1) combinations; splits into:
- ___11 = g(n-2)
- ___01 = g(n-2)
- ___21 = g(n-2)
since they are all legal strings, we keep all of them, so you add g(n-1) to your recursion.
___0 = g(n-1) combinations; splits into:
- ___00 = g(n-2)
- ___10 = g(n-2)
- ___20 = g(n-2), All legal: add g(n-1) to recursion
___2 = g(n-1) combinations; splits into:
Summing everything together, you note that 02 contributes: g(n-2) - g(n-3), and, having already established, by virtue of the ternary property, that g(n-1) = 3g(n-2), you get that __2's contribution is g(n-1) - g(n-3).
Summing everything together, you have:
$$
3g(n-1) - g(n-3) = g(n)
$$
And that just makes sense to me, because this is a tree we are talking about...and this explanation unfolds like a breadth first search reinterpreted as a recursion. Super intuitive.