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, checks if any two numbers in the BST add up to the target, and prints the result.
📋 What You'll Learn
Create a BST with exact phone numbers: 10, 5, 15, 3, 7, 18
Create a variable called
target with value 22Write a function
findTarget that returns true if two numbers in the BST add up to targetPrint
true or false depending on the result💡 Why This Matters
🌍 Real World
Finding pairs of numbers that sum to a target is useful in financial applications, phone number analysis, and data validation.
💼 Career
This problem helps prepare for coding interviews and teaches tree traversal and hash map usage, common in software engineering roles.
Progress0 / 4 steps