BST vs Hash Map Trade-offs for Ordered Data
📖 Scenario: Imagine you are building a simple contact list app. You want to store contacts with their phone numbers. Sometimes, you need to find a contact quickly by name. Other times, you want to list all contacts in alphabetical order.Two common ways to store this data are using a Binary Search Tree (BST) or a Hash Map. Each has its strengths and weaknesses.
🎯 Goal: Build a small program to store contacts using a map, then add a sorted list of contact names using a BST-like structure. This will help you see the difference in how data is stored and accessed.
📋 What You'll Learn
Create a map to store contact names and phone numbers.
Create a slice to hold contact names for sorting.
Sort the contact names alphabetically.
Print the contacts in alphabetical order.
💡 Why This Matters
🌍 Real World
Contact lists, phone books, and any app needing fast lookup and ordered display of data.
💼 Career
Understanding data structures like maps and trees helps in designing efficient software for search, sorting, and data management.
Progress0 / 4 steps