I am a newbie to data structures, and I was trying to learn threaded binary tree. My question is: after a tree has been threaded and if I need to add some nodes to the tree, should I un-thread it before adding nodes and then thread it again, or are there some better ways to add new nodes to a threaded binary tree? Please help me.
1 Answer
You don't want to unthread the whole tree, because that takes O(n) operations in the number of nodes.
Instead, just correct the pointers in the nodes you "touch".
Here's a tutorial that might help.