You are on page 1of 2

(/learn)

Problem Set 4
Question 1

Kim is new to programming and designs the following hash function for her
hash table.

int computeHash(int key) {

int hash = 0;
for (int i = 1; i <= key; i++) {
hash += i;
}

return hash;
}

a- What is the time complexity of the hash function?

b- Can we make the hash function take constant time?

c- What is the space requirements/complexity if Kim chooses to stick with


her hash function and wants to ensure no collisions happen?

←    Back Next    →
(/courses/big- (/courses/big-
MARK AS COMPLETED
o- o-
notation- notation-
for- for-
interviews- interviews-
Tree Structures Solution Set 4
and- and-
beyond/qVlxqvG4E33) beyond/RMLzWp8G2WO)

Ask a Question
Report
(https://discuss.educative.io/c/big-o-for-coding-interviews-and-beyond-c-h-
an Issue
afzal/data-structures-problem-set-4)
(/learn)

You might also like