Skip to main content
Engineering LibreTexts

11.1: Hashing

  • Page ID
    34694
  • Suppose we want to design a system for storing employee records keyed using phone numbers. And we want following queries to be performed efficiently:

    1. Insert a phone number and corresponding information.
    2. Search a phone number and fetch the information.
    3. Delete a phone number and related information.

    We can think of using the following data structures to maintain information about different phone numbers.

    1. Array of phone numbers and records.
    2. Linked List of phone numbers and records.
    3. Balanced binary search tree with phone numbers as keys.
    4. Direct Access Table.

    For arrays and linked lists, we need to search in a linear fashion, which can be costly in practice. If we use arrays and keep the data sorted, then a phone number can be searched in O(Logn) time using Binary Search, but insert and delete operations become costly as we have to maintain sorted order.

    Geeks for Geeks have their own YouTube channel - including a video on Hashing.

    "Hashing | Set 1 (Introduction)" by Connor Fehrenbach is licensed under CC BY-SA 4.0

    • Was this article helpful?