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


Please Help Members By Posting Answers For Below Questions

What is use of integral promotions in c?

660


‘ C’ PROGRAME TO SHOW THE TYPE OF TRANGLE BY ACCEPTING IT’S LENGTH .

2366


Tell me when would you use a pointer to a function?

601


Can the curly brackets { } be used to enclose a single line of code?

709


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

665






What are the two forms of #include directive?

640


What is volatile variable in c?

654


What is a stream?

639


How can I change their mode to binary?

687


What header files do I need in order to define the standard library functions I use?

535


What are formal parameters?

652


What does 3 periods mean in texting?

593


Explain setjmp()?

651


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?

571


Explain how can you determine the size of an allocated portion of memory?

616