© Elshad Karimov 2020
E. KarimovData Structures and Algorithms in Swifthttps://doi.org/10.1007/978-1-4842-5769-2_7

7. Hash Table

Elshad Karimov1 
(1)
New York, New York, USA
 

A hash table is a data structure of “associative arrays” that groups values in an index and sorts and retrieves data using a key/value mapping. It accomplishes the same goal in some cases like Swift dictionaries. However, the efficiency of hash tables is better than dictionaries. The time complexity for searching, inserting, and deleting is on average O(1), which means that regardless of the size of the input operation time remains constant. This solves the problem of the linear search operation which is costly and the time complexity is O(n). By calculating the hash value, we ...

Get Data Structures and Algorithms in Swift: Implement Stacks, Queues, Dictionaries, and Lists in Your Apps now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.