GeeksforGeeks » Interview Questions

Amazon Interview Question for Software Engineer/Developer about Data Structure

(4 posts)
  1. freak
    guest
    Posted 4 months ago #

    data structure TO use to design a phonebook. What is time complexity for retrieving, adding etc

  2. ANkit Gupta
    guest
    Posted 4 months ago #

    Use "http://www.geeksforgeeks.org/archives/13067" for referral

  3. abhishek
    guest
    Posted 4 months ago #

    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.

  4. rageguy
    Member
    Posted 3 months ago #


Reply

You must log in to post.

RSS feed for this topic