In hashing, what is the primary purpose of a hash function?
25 views
- To sort data in ascending order
- To map keys to indices in a hash table (Correct Answer)
- To traverse a linked list
- To create a binary tree
Explanation
A hash function maps a given key to an index in a hash table, allowing constant-time access for insertion, deletion, and search operations in ideal conditions.