← Back to challenges

Minimum and Maximum Value in BST

JavaScriptHarddata_structuresarrayslanguage_fundamentals

Instructions

Given a Binary Search Tree (BST) implementation, complete the minimum, and maximum function which is present in the BST class. Here you have to find the max value, min value of the whole tree.

Examples

data = [10, 4 , 20 , 1 , 5]

maximum()  ➞ 20
      10
      /   \
    4    20
  /  \
1    5

data = [100, 70, 200, 34, 80, 300]

minimum() ➞ 34

       100
       /    \
    70    200
  /    \          \
34   80      300

Notes

Maximum and Minimum value of the whole tree.

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.