BST vs Hash Map Trade-offs for Ordered Data
📖 Scenario: You are building a simple contact list app. You want to store contacts with their phone numbers. You need to quickly find a contact's number by name. Also, you want to see contacts in alphabetical order sometimes.
🎯 Goal: Build a program that stores contacts in a dictionary-like structure, then extracts and prints contacts in alphabetical order using a binary search tree (BST) approach.
📋 What You'll Learn
Create a dictionary called
contacts with exact entries: "Alice": "1234", "Bob": "5678", "Charlie": "91011"Create an empty binary search tree structure called
bst to store contact namesInsert all contact names from
contacts into bst in alphabetical orderPrint the contact names in alphabetical order from
bst💡 Why This Matters
🌍 Real World
Contact lists, phone books, and any app needing fast lookup plus ordered display use these data structures.
💼 Career
Understanding when to use hash maps or BSTs helps in software engineering roles involving data storage, search optimization, and UI display.
Progress0 / 4 steps