Amazon.com

www.amazon.com

Interview Question

Software Development Engineer/Test Interview

There's an array and a hash function. There are many

  incoming elements to be inserted into the array, and the index for each one is the hash key obtained from the hash function. There are four methods for this structure: insert, delete, find, printAll. (1) printAll should print all the elements in the array in the order they were inserted. How to implement this? (2) (After I have answered the first question) How to implement delete if your approach for (1) is used?
Answer

Interview Answer

1 Answer

0

(1) Use a linked list, each item is a pointer to an element in the array.
(2) The linked list is doubly linked list. Modify the structure of the array, such that each item in the array contains not only the element but also a pointer to the corresponding linked list item.

Interview Candidate on May 17, 2012

Add Answers or Comments

To comment on this, Sign In or Sign Up.