solve4 - CSE2011F06/HR - Solution of #4 1. Given the hash...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
CSE2011F06/HR - Solution of #4 1. Given the hash function. .. a. Depending on implementation, you can insert a colliding item at the front or rear of the list. b. Here is the resulting hash table: c. Here is the resulting hash table: d. Note that 1989 cannot be inserted because all the possible locations are taken. Here is the resulting hash table: 2. Here is a possible modification. Add the attribute: private int deleted; and set it to -1 at the top of findPos . Next, add the following statement before the end of the while loop in findPos : if (!isActive(currentPos)) this.deleted = currentPos; 3. Here is the full implementation. 4. We want to insert the elements. .. a. Here is the heap b. Here is the heap c. Here are the two resulting heaps 5. The linear buildHeap algorithm is always faster, even for random data. Write a very short client of the BinaryHeap class in the program directory. Use System.currentTimeMillis() to time the invocation of N inserts versus the invocation of the copy constructor. The speed up is clear for all
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 12/11/2010 for the course CSE CSE 2011 taught by Professor Neugyen during the Fall '09 term at York University.

Page1 / 2

solve4 - CSE2011F06/HR - Solution of #4 1. Given the hash...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online