CS 2420 Summer 2008 Homework 3: Splay Trees and Hash Tables - Prof. Vicki H. Allan, Assignments of Computer Science

Written homework for cs 2420 summer 2008, focusing on splay trees and hash tables. The tasks include inserting and deleting values in top-down splay trees and b-trees, understanding primary and secondary clustering, and analyzing different collision resolution schemes. Additionally, students are asked to evaluate the appropriateness of various hash functions.

Typology: Assignments

Pre 2010

Uploaded on 07/30/2009

koofers-user-ya8
koofers-user-ya8 🇺🇸

10 documents

1 / 5

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CS 2420 Summer 2008
Written Homework 3
1. Show the result of inserting 10 into the top-down splay tree shown below.
2. Show the result of deteteMax from the top-down splay tree show below:
pf3
pf4
pf5

Partial preview of the text

Download CS 2420 Summer 2008 Homework 3: Splay Trees and Hash Tables - Prof. Vicki H. Allan and more Assignments Computer Science in PDF only on Docsity!

CS 2420 Summer 2008 Written Homework 3

  1. Show the result of inserting 10 into the top-down splay tree shown below.
  2. Show the result of deteteMax from the top-down splay tree show below:
  1. For the B-tree below (with L=5 and M=5), show the tree after inserting 60, 61, 62, 100.
  2. For the B-tree below (with L=5 and M=5), show the tree after deleting 98, 85, 83,49, 50.
  3. The definitions of primary and secondary clustering are sometimes difficult to get straight.

In primary clustering, not only do items collide because they hash to the same location, but one item may collide with the alternate location for another. This occurs in linear probing. When the item that hashes to x is placed in y , items that hash to either x or y both try the same next location.

In secondary clustering, two items that hash to the same location follow the same probe sequence for subsequent locations. This happens in quadratic probing. Only items that hash to location x continue to try the same sequence of alternate locations. If something has primary clustering, it will also have secondary clustering.

If a hash method does not exhibit primary or secondary clustering, it is termed non-clustering. This happens with double hashing. Even items which hash to the same location do not continue to try the same sequence of alternate locations because each is using a different step value.

Notice that non-clustering methods are the best, and methods that exhibit primary clustering are the worst.

Consider the following collision resolution schemes. Indicate whether they are non-clustering, secondary clustering, or primary clustering.

a. You use linear probing, but always increment by 3 (rather than 1) in the event of a collision.

  1. Using a hash table with eleven locations and hashing function h(i) = i % 11 , show the hash table that results when the following integers are inserted in the order given: 26, 42, 5, 44, 92, 59, 40, 36, 12. Show the hash table using: a. Linear probing b. Quadratic probing c. Double hashing using the secondary hash function h 2 = x%9 + 1 to compute the personalized step. d. Chaining

Linear Probing

Quadratic Probing Double Hashing Chaining 0 1 2 3 4 5 6 7 8 9

10