Validate if Tree is BST
📖 Scenario: You are working with a simple binary tree structure in JavaScript. Your task is to check if this tree follows the rules of a Binary Search Tree (BST).A BST is a tree where for every node, all values in the left subtree are smaller, and all values in the right subtree are larger.
🎯 Goal: Build a program that creates a binary tree, sets up a helper function to check BST rules, and then prints whether the tree is a valid BST or not.
📋 What You'll Learn
Create a binary tree with exact nodes and values
Add a helper function to validate BST rules
Use recursion to check the tree
Print 'true' if the tree is a BST, otherwise 'false'
💡 Why This Matters
🌍 Real World
Checking if a tree is a BST is important in databases and search algorithms where data needs to be organized for fast lookup.
💼 Career
Understanding BST validation helps in roles like software development and data engineering where tree data structures are common.
Progress0 / 4 steps