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
Hai what is the different types of versions and their differences
What is "Hungarian Notation"?
What does volatile do?
Are there namespaces in c?
When should the const modifier be used?
By using C language input a date into it and if it is right?
In c programming, explain how do you insert quote characters (? And ?) Into the output screen?
Are pointers integer?
What are types of preprocessor in c?
Explain the use of 'auto' keyword in c programming?
What are the similarities between c and c++?
What is c++ used for today?
write a c program to find the sum of five entered numbers using an array named number
What is the use of a conditional inclusion statement in C?
What is || operator and how does it function in a program?