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
What is use of integral promotions in c?
‘ C’ PROGRAME TO SHOW THE TYPE OF TRANGLE BY ACCEPTING IT’S LENGTH .
Tell me when would you use a pointer to a function?
Can the curly brackets { } be used to enclose a single line of code?
what are the advanced features of functions a) function declaration and prototypes b) calling functions by value or by reference c) recursion d) all the above
What are the two forms of #include directive?
What is volatile variable in c?
What is a stream?
How can I change their mode to binary?
What header files do I need in order to define the standard library functions I use?
What are formal parameters?
What does 3 periods mean in texting?
Explain setjmp()?
Write a program to input the price of 1 burger and the number of burgers eaten by a group of friends .print the total amount to be paid by the group?
Explain how can you determine the size of an allocated portion of memory?