Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


how to find out the inorder successor of a node in a tree??

Answers were Sorted based on User's Feedback



how to find out the inorder successor of a node in a tree??..

Answer / atul kabra

Suppose we want to fint the inorder successor of N. Then
traverse one time right from N. And then traverse a left
subtree until u will get left pointer null node.

s=n->right;
while(s->left!=NULL)
s=s->left;

printf("\nInoder Successor is %d",s->info);

Is This Answer Correct ?    27 Yes 42 No

how to find out the inorder successor of a node in a tree??..

Answer / 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

More C Interview Questions

what is the purpose of the code, and is there any problem with it. bool f( uint n ) { return (n & (n-1)) == 0; }

1 Answers   Google,


find largest of 3 no

8 Answers  


Find the O/p of the following 1) #include int main() { char c='1'; int j=atoi(c); }

4 Answers   Subex,


what is the use of #pragma pack, wer it is used?

2 Answers   Wipro,


Between macros and functions,which is better to use and why?

0 Answers  


do u print this format '(((())))'. This brackets is based on user input like 4 or 5 or 6,without using any loop's?

1 Answers   Oracle,


Write a program that takes a 5 digit number and calculates 2 power that number and prints it.

1 Answers  


What is function in c with example?

0 Answers  


Read N characters in to an array . Use functions to do all problems and pass the address of array to function. 2. Enter alphanumeric characters and form 2 array alphaets and digits.Also print the count of each array.

0 Answers  


explain what is an endless loop?

0 Answers  


How many types of errors are there in c language? Explain

0 Answers  


How many data structures are there in c?

0 Answers  


Categories