I love that little Flag trick! So helpful, esp for in-order traversal, which Grimaldi explains very cryptically. I don't know why Grimaldi doesn't mention the flag trick, sometimes I think he likes his textbook to be opaque...
My professor took forever to explain this and I didn't understand it at all. You explain it in one fourth of the time and I completely understand it. I wish you were my professor.
I never thought of thinking it in that flag trick! It's extremely easy to understand. My lecturer never would've thought of that so thank you very much for this
you are the best, I didn't go to the class even once, but after I saw your video for final exam, you show me best path to get everything, I really appreciate it
For in-order traversal on unary operators, it seems that you should assume the edge is on the right side of the imaginary flag. Take -(x + 8) for example: ( - ) ¦ \ \ ( + ) / ¦ \ / \ ( x ) ( 5 ) ¦ ¦ ¦ = imaginary flag Perhaps a way to remember this is that -(x + 8) would be the same as 0-(x + 8). Or imagine the unary operator was the square root: √(x + 5) ( √ ) ¦ \ \ ( + ) / ¦ \ / \ ( x ) ( 5 ) ¦ ¦ ¦ = imaginary flag
It's just a trick for figuring out the order that each node should be written out if travelling counter-clockwise around the tree. It's not necessary to understand. Some people work better with visualizations.