GeeksforGeeks » Interview Questions
Amazon Interview Question for Software Engineer/Developer about Data Structure
(4 posts)-
data structure TO use to design a phonebook. What is time complexity for retrieving, adding etc
-
Use "http://www.geeksforgeeks.org/archives/13067" for referral
-
Or simply ... you could just assume the following :
Suppose there are n numbers and suppose a phone number has 10 digits.
so total phone numbers could be 10^10.
But this is not the case the actual numbers possible are some finite and limited numbers which is n.
So take an array of size n.Since all phone numbers will be unique, apply a hash function h = (ph. no. % n) which is also the index of the information of that particular phone number.
retrieving complexity would be O(1) and for adding we would have to rehash every time if we take n sized array. So to be on safe side, take load factor to be 0.75.
-
This link might help
http://mycareerstack.com/q.php?id=116
Reply
You must log in to post.