Answer:
Find the no. of elements on the left side.
If it is n-1 the root is the median.
If it is more than n-1, then it has already been found in the left subtree.
Else it should be in the right subtree.
If it is n-1 the root is the median.
If it is more than n-1, then it has already been found in the left subtree.
Else it should be in the right subtree.
Previous Question | Next Question |
Define string in an algorithmic notation and an example to support it? | What are the arguments present in pattern matching algorithms? |