BST Find Maximum Element
📖 Scenario: You are working with a Binary Search Tree (BST) that stores numbers. You want to find the largest number stored in the tree.Think of the BST like a family tree where each node has a number. The right child always has a bigger number than its parent. So, the biggest number is the rightmost node.
🎯 Goal: Build a simple BST with given numbers, then write code to find and print the maximum number in the BST.
📋 What You'll Learn
Create a BST node class called
TreeNode with value, left, and right propertiesCreate a BST by manually linking nodes with these exact values: 15, 10, 20, 8, 12, 17, 25
Write a function called
findMax that finds the maximum value in the BST by moving rightPrint the maximum value found in the BST
💡 Why This Matters
🌍 Real World
BSTs are used in databases and search engines to quickly find the largest or smallest values.
💼 Career
Understanding BSTs and how to find max/min values is important for software engineers working with data structures and algorithms.
Progress0 / 4 steps