Solved

largest key in a binary search tree

Posted on 2012-03-31
2
414 Views
Last Modified: 2012-03-31
To find the largest key in a binary search tree, is this correct:  start at the root, and recursively visit the node.  When the right child is null, the node contains the largest key.
0
Comment
Question by:HLRosenberger
2 Comments
 
LVL 31

Accepted Solution

by:
GwynforWeb earned 500 total points
ID: 37791607
That is correct, ie always go right as everything to the left will be smaller. Until there is  no right child to visit.

 In pseudo code it becomes


function findLargest(node){
  if (node.rightChild == null) return node.value
  return findLargest(node.rightChild)
}

findLargest(root)
0
 
LVL 1

Author Closing Comment

by:HLRosenberger
ID: 37791625
Thank You
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Complex Numbers are funny things.  Many people have a basic understanding of them, some a more advanced.  The confusion usually arises when that pesky i (or j for Electrical Engineers) appears and understanding the meaning of a square root of a nega…
Article by: Nicole
This is a research brief on the potential colonization of humans on Mars.
This video discusses moving either the default database or any database to a new volume.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now