Two Sum in BST
📖 Scenario: You are working with a phone book stored as a Binary Search Tree (BST). Each node contains a phone number. You want to find if there are two phone numbers in the BST that add up to a specific target sum.
🎯 Goal: Build a program that creates a BST with given phone numbers, sets a target sum, and checks if any two numbers in the BST add up to that target.
📋 What You'll Learn
Create a BST with the exact phone numbers: 10, 5, 15, 3, 7, 18
Create an integer variable called
target with the value 22Implement a function
findTarget that returns true if two numbers in the BST add up to targetPrint
true or false depending on whether such a pair exists💡 Why This Matters
🌍 Real World
Finding pairs of numbers that add up to a target is useful in financial applications, phone number analysis, and data validation.
💼 Career
Understanding BSTs and hash sets is important for software engineering roles that involve data structures and algorithm optimization.
Progress0 / 4 steps