Computer Science 245
Spring 2009
Homework 6: Sorting, Hash Tables & Disjoint Sets
Due Wednesday, April 1st, 3:30 p.m.
- The following array is to be sorted using radix sort
(base-10). Shoe the result after sorting each digit:
| 544 |
322 |
654 |
376 |
192 |
919 |
125 |
129 |
354 |
255 |
118 |
411 |
617 |
432 |
521 |
444 |
- You are about to partition the following list, using the last element as a pivot:
| 2 |
20 |
4 |
5 |
21 |
12 |
9 |
16 |
22 |
7 |
6 |
15 |
Show the list after the partition step.
- The following elements are inserted into a hash table of
size 11 (in this order): 5, 27, 16, 6, 7
- Show the resulting hash table, assuming open hashing
(separate chaining, closed addressing)
- Show the resulting hash table, assuming closed hashing (open addressing) and linear probling
- Show the resulting hash table, assuming closed hashing (open addressing) and quadratic probling
- Show the resulting hash table, aassiming closed hashing (open
addressing) and double hashing (second hash function: hash2(x) = (x %
5) + 1
- For an implementation of disjoint sets that uses union by
rank by not path compression, show the resulting Parent aray after the
following operations:
- MakeSets(10)
- Union(4,5)
- Union(6,7)
- Union(5,6)
- Union(7,8)
- Union(9,2)
- Union(2,5)
- For an implementation of disjoint sets that uses union by
rank but not path compression, give a sequence of Union calls
that result in the tree with the greatest possible height, for a set of 16 elements, and
show the resulting Parent array.