Please help. It\'s my second time posting this question. This question was answe
ID: 671200 • Letter: P
Question
Please help. It's my second time posting this question. This question was answered nicely here before, but part (b) is in C language. I am looking for Java answer.
A binary search tree with N nodes has N+1 null references, half the space allocated in a binary search tree for links is wasted. Suppose that if a node has a null left child, we make its child link to its inorder predecessor and if a node has a null right child, we make its right child link to its inorder successor, making a threaded tree.
a) How to distinguish threads from real children links?
I got this answer and think it's good: One can distinguish threads from real child links by storing bits to the node. Or one can also detect cycle during tree traversal.
b) Write routines to perform insertion and deletion into a tree threaded in this manner.
I am not sure if you have to write a java program for this, or we can just describe the routines. If you can provide a Java program, it will help me to learn so much, and I will write the routines with that code.
Thank you very much.
P.S.1:This question comes from exercise 4.50 Data Structures and Algorithm Analysis in Java, 3rd Ed., Mark Weiss.