• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 427
  • Last Modified:

largest key in a binary search tree

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.
1 Solution
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)

HLRosenbergerAuthor Commented:
Thank You
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now