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 the condition that is applied with ?: Operator?
#include main() { int *p, *c, i; i = 5; p = (int*) (malloc(sizeof(i))); printf(" %d",*p); *p = 10; printf(" %d %d",i,*p); c = (int*) calloc(2); printf(" %d ",*c); }
What is the difference between array and structure in c?
Write a C/C++ program that connects to a MySQL server and checks if the InnoDB plug-in is installed on it. If so, your program should print the maximum number of concurrent threads that the InnoDB plug-in can create.
Place the #include statement must be written in the program?
Write a code to determine the total number of stops an elevator would take to serve N number of people.
What is indirection? How many levels of pointers can you have?
Explain how can you restore a redirected standard stream?
What is advantage of pointer in c?
What is the size of a union variable?
write a program in C that prompts the user for today's date,tomorrow's date and display the results.Use structures for today's date,tomorrow's date and an array to hold the days for each month of the year.
Explain the bubble sort algorithm.
Explain what does the characters 'r' and 'w' mean when writing programs that will make use of files?
What is the basic structure of c?
Explain heap and queue.