You are not logged in. Please login at www.codechef.com to post your questions!

×

Finding the next larger element in BST.

Note that x is a node in the BST. Find the next larger element in BST . i.e next-larger(x).

asked 10 Nov '16, 00:03

rashedcs's gravatar image

1★rashedcs
487419
accept rate: 4%


Psedocode :


if (rightChild == NULL)     return minimum(right);
else                                   y = parent(x);

while(y!= NULL && x=right(y) )
{
  x = y;
  y = parent(y);
}
return y;

link

answered 10 Nov '16, 00:18

rashedcs's gravatar image

1★rashedcs
487419
accept rate: 4%

edited 10 Nov '16, 00:19

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×761

question asked: 10 Nov '16, 00:03

question was seen: 244 times

last updated: 10 Nov '16, 00:19