Grokking the Engineering Manager Coding Interview

0% completed

Introduction to Hashing

Implementing Hashtables in Different Languages

Code Examples

Limitations of Hashtables

Implementing Hashtables in Different Languages

Different programming languages provide built-in implementations of Hashtables.

LanguageAPI (Hashtable Implementation)
Javajava.util.HashMap
Pythondict
C++std::unordered_map
JavaScriptObject or Map
C#Dictionary<TKey, TValue>
Gomap

Code Examples

Python3
Python3

. . . .

Limitations of Hashtables

Although Hashtables are incredibly fast and efficient, they come with some drawbacks.

LimitationExplanation
High Memory UsageHashtables require extra memory to store keys, values, and handle collisions.
No OrderingUnlike arrays or linked lists, Hashtables do not maintain insertion order.
Performance DegradationIf too many collisions occur, lookup time can degrade from O(1) to O(n).
Resizing CostWhen resizing occurs, all elements need to be rehased, causing a temporary slowdown.

Let's start solving the coding problems on Hashtables.

Mark as Completed
D

designgurus.cedar998

· 5 months ago

While I appreciate the theory of the three introductory lessons to the "Pattern: Hash Maps" section, I think they paint a misleading picture for someone focused on practical knowledge for the coding interview.

For example, I would have appreciated this page explaining (for JavaScript) when to use Set (no keys), Map (any key), and Object (string keys) for various common problems.

On This Page

Implementing Hashtables in Different Languages

Code Examples

Limitations of Hashtables