sp09-sl-s3 - ECE 3035 4 problems 5 pages Problem 1(1 part 24 points Computing Mechanisms Exam Three Solutions Spring 2009 8 April 2009 Hash Tables and

# sp09-sl-s3 - ECE 3035 4 problems 5 pages Problem 1(1 part...

This preview shows page 1 - 3 out of 4 pages.

ECE 3035 Computing Mechanisms Spring 2009 4 problems, 5 pages Exam Three Solutions 8 April 2009 1 Problem 1 (1 part, 24 points) Hash Tables and Heap Consider an open hash table composed of a four-bucket table, with each bucket containing a variable length list. Each list entry has three slots <key, value, next> corresponding to the three word groupings in the entries section. The hash function is key mod four . Inserted entries are appended to the end of a bucket list. Deallocated entries are maintained on a LIFO free list. When the free list is empty, new entry objects are allocated from heap memory. Accesses are listed as <op, key, [value]>. Simulate the access list below and draw the ending state. Assume the hash table is initially empty, the heap pointer is initially 5016 and the free pointer is initially 0. Heap Pointer 5016 5028 5040 5052 5064 Free List 0000 5040 0000 5016 Buckets 5000 5016 5052 5004 5008 5028 5012 Entries 5016 7004 5040 7000 7006 5064 5088 5020 111 555 5044 333 0 666 5068 5092 5024 0 5040 5052 0 5048 0 5052 0 5072 5096 5028 7002 5052 7008 5076 5100 5032 222 5056 444 5080 5104 5036 0 5040 5060 0 5084 5108 Hash Table Access Trace # op key value # op key value 1 insert 7004 111 5 insert 7004 555 2 insert 7002 222 6 remove 7000 n/a 3 insert 7000 333 7 insert 7006 666 4 insert 7008 444 8 remove 7004 n/a