A
A
albertalexandrov2018-09-17 19:26:21
Python
albertalexandrov, 2018-09-17 19:26:21

What is the worst case for hash tables?

Hey!
They write that for hash tables, the worst case for lookups, insertions, and deletions is O(n). What is this worst case? Rebuilding a table index?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
GavriKos, 2018-09-17
@GavriKos

Do you have an example? This is when all elements have the same hash - it is impossible to find the desired element only by the hash and you have to search manually. Those. the table roughly speaking becomes an ordinary array.

T
Teslaman, 2018-09-17
@Teslaman

In collisions (hash matches), the elements are usually added to a linked list. Searching this linked list is O(n).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question