chickenandfries
February 2nd, 2008, 07:08 AM
How do I transform a non-threaded binary tree into an completely inorder threaded binary tree wherein the null left and right sons of a leaf are made to point to its inorder predecessor and inorder successor respectively?
CMPITG
February 4th, 2008, 01:37 AM
I'm not sure I understand your question. Can you give an example about it?
chickenandfries
February 14th, 2008, 06:18 AM
I was planning to completely thread my binary tree inorder i.e. point the null left son pointers to the nodes' inorder predecessor and the null right son pointers to the node nodes' inorder successor. I've done it already. What I did was traverse the tree in inorder twice, distinguishing the "real" links from the threads: first traversal threads the null left son pointers to the inorder predeccessor and the other one threads the null right son pointers to the inorder successor. For the first traversal, the current node being visited is stored in some variable, say "pred". If the current node's left son is NULL, point the left son pointer to pred. For the second traversal, the current is stored again in some variable, say "suc". If the suc's right son is NULL, point it to the current node.