Solved

largest key in a binary search tree

Posted on 2012-03-31
2
419 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article seeks to propel the full implementation of geothermal power plants in Mexico as a renewable energy source.
We are taking giant steps in technological advances in the field of wireless telephony. At just 10 years since the advent of smartphones, it is crucial to examine the benefits and disadvantages that have been report to us.
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

732 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