CoolInterview.com - World's Largest Collection of Interview Questions
Start Your Own website Now
Sponsored Links

Interview Questions
Our Services

Get 9,000 Interview Questions & Answers in an eBook.


  • 9500+ Pages
  • 9000 Question & Answers
  • All Tech. Categories
  • 14 MB Content

    Get it now !!



    Send your Resume to 6000 Companies


  • INTERVIEW QUESTIONS ALGORITHM DETAILS
    Question :
    How to find median of a BST?
    Category Algorithm Interview Questions
    Rating (0.5) By 591 users
    Added on 9/11/2009
    Views 1667
    Rate it!
    Answers:

    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.



    Its better to count all the elements in the tree in one traversal and then use inorder traversal to print the n/2th element in second traversal.



    Posted by: game    

    Contact game Contact game

    Its simply the ROOT of the tree, with a condition that the tree is Sorted and has equal number of nodes on both sides - left and right.



    Posted by: Pinki Ruparel    

    Contact Pinki Ruparel Contact Pinki Ruparel

    allgo



    Posted by: ankur    

    Contact ankur Contact ankur

    If you have the better answer, then send it to us. We will display your answer after the approval.
    Rules to Post Answers in CoolInterview.com:-

  • There should not be any Spelling Mistakes.
  • There should not be any Gramatical Errors.
  • Answers must not contain any bad words.
  • Answers should not be the repeat of same answer, already approved.
  • Answer should be complete in itself.
  • Name :*
    Email Id :*
    Answer :*
    Verification Code Code Image - Please contact webmaster if you have problems seeing this image code Not readable? Load New Code
    Process Verification  Enter the above shown code:*
    Inform me about updated answers to this question

       
    Related Questions
    View Answer
    How do you apply Binary Search on 2D array supposed you have 2D array with integers sorted both horizontally and vertically. If you find any occurrence of the value you are looking for you return true else false. What is the complexity?

    For example the 2D array could look like the following

    1 4 5 6
    2 5 7 9
    View Answer


    Please Note: We keep on updating better answers to this site. In case you are looking for Jobs, Pls Click Here Vyoms.com - Best Freshers & Experienced Jobs Website.

    View ALL Algorithm Interview Questions

    User Options
    Sponsored Links


    Copyright ©2003-2014 CoolInterview.com, All Rights Reserved.
    Privacy Policy | Terms and Conditions

    Download Yahoo Messenger | Placement Papers| FREE SMS | ASP .Net Tutorial | Web Hosting | Dedicated Servers | C Interview Questions & Answers

    Testing Articles | Testing Books | Testing Certifications | Testing FAQs | Testing Downloads | Testing Interview Questions | Testing Jobs | Testing Training Institutes


    Cache = 0.03125 Seconds