You are on page 1of 2

CSC2103: Data Structures & Algorithms

Week 7 Activities:

The aim of this exercise is to explore and understand on this week topic which
are Indexing and Hashing methods.

Task 1:
Explain the following terms
1) Hashing
2) Open addressing
3) Separate Chaining
4) Collision

Task 2:
Consider a hash table using open addressing and a linear probing to resolve
collisions. The hash table size is m = 7 and the employed hash function is

h(k) = k % m (note: % is modulo division)

where k is an integer number.

Assume that in an empty instance of the aforementioned hash table we


inserted the following numbers (integer), from left to right. Draw the resulting
mapping table.

26, 32, 19, 11, 35, 9

If the hash table in the previous question uses a separate chaining technique
to resolve collision, can you describe how the same ordered list of number
would be inserted?

Task 3:
Compile and test the attached Java program (Lab7.java) and complete the
following tasks:

1. Execute the program and list the output.


2. Explain the hash function given in the program and what it does.
3. Is there any collision for the given data items?
4. Draw sketches of open addressing and separate chaining to show the
executed result.
5. Modify the hash function to avoid collision (no redundant hash).

You might also like