how to find out the inorder successor of a node in a tree??
Answer Posted / shruti
inorder trraversal is
left - vertex - right.
hence to find the successor of a node.
consider N node . we have to find the inorder successor of
N.
then,
if(n -> right != NULL)
n = n -> right. /* this is the successor of n.
else
{
n = pop();
(/* we have to pop the address of the node above n, which
we have pushed earlier while traversing leftwards*/)
/*n will be hte successor node.
}
in inorder traversal we have number in ascending order in a
binary search tree.
hence the successor always is to the right, if exists,
or one level above.
**Go through the inorder traversal program to get a better
picture.
| Is This Answer Correct ? | 11 Yes | 27 No |
Post New Answer View All Answers
explain what are actual arguments?
How can I remove the trailing spaces from a string?
What are the types of data files?
Explain what is the benefit of using #define to declare a constant?
What is queue in c?
List the difference between a While & Do While loops?
What does. int *x[](); means ?
When should the const modifier be used?
why to assign a pointer to null sometimes??how can a pointer we declare get assigned with a garbage value by default???
What are external variables in c?
Explain output of printf("Hello World"-'A'+'B'); ?
What is meant by operator precedence?
Write a program to reverse a given number in c?
process by which one bit patten in to another by bit wise operation is? (a) masking, (b) pruning, (c) biting, (d) chopping,
What is the collection of communication lines and routers called?