Recall & Review
beginner
What is a key advantage of a Binary Search Tree (BST) over a Hash Map when working with ordered data?
A BST maintains elements in sorted order, allowing efficient in-order traversal to access data in ascending or descending order.
Click to reveal answer
intermediate
Why might a Hash Map be less suitable than a BST for range queries?
Hash Maps do not maintain any order, so range queries require checking all keys, making them inefficient compared to BSTs which can quickly navigate ranges.
Click to reveal answer
intermediate
In terms of average time complexity, how do BSTs and Hash Maps compare for search operations?
Hash Maps offer average O(1) search time, while BSTs offer O(log n) if balanced; however, BSTs provide ordered data access which Hash Maps do not.
Click to reveal answer
intermediate
What is a potential downside of using a BST compared to a Hash Map?
BSTs can become unbalanced, leading to O(n) worst-case search time, while Hash Maps maintain consistent average O(1) search time regardless of data order.
Click to reveal answer
advanced
How does memory usage typically compare between BSTs and Hash Maps?
Hash Maps often use more memory due to storing keys, values, and handling collisions, while BSTs store nodes with pointers but usually have less overhead.
Click to reveal answer
Which data structure is best suited for retrieving data in sorted order?
✗ Incorrect
Binary Search Trees keep data sorted, enabling ordered retrieval.
What is the average time complexity of search in a Hash Map?
✗ Incorrect
Hash Maps provide average constant time O(1) search.
Why might a BST perform worse than a Hash Map in some cases?
✗ Incorrect
Unbalanced BSTs degrade to linear search time.
Which data structure is more efficient for range queries?
✗ Incorrect
BSTs allow efficient range queries due to ordered structure.
Which data structure typically uses more memory due to collision handling?
✗ Incorrect
Hash Maps use extra memory for buckets and collision resolution.
Explain the trade-offs between using a Binary Search Tree and a Hash Map for storing ordered data.
Think about order, speed, and memory.
You got /5 concepts.
Describe scenarios where a BST is preferred over a Hash Map and vice versa.
Consider what you need: order or speed.
You got /4 concepts.