0% found this document useful (0 votes)
2 views2 pages

Data Structures Assignment8

This document outlines the instructions for Group Assignment 8 in COMP 251, focusing on Maps and Hash Tables. It includes tasks for creating an Unsorted Map and a Hash Table with separate chaining, with specific requirements for code implementation and output formatting. An optional question is also provided for additional practice on Hash Table concepts using linear probing.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views2 pages

Data Structures Assignment8

This document outlines the instructions for Group Assignment 8 in COMP 251, focusing on Maps and Hash Tables. It includes tasks for creating an Unsorted Map and a Hash Table with separate chaining, with specific requirements for code implementation and output formatting. An optional question is also provided for additional practice on Hash Table concepts using linear probing.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Group Number:

Student Names:
Marks: 4 points
COMP 251: Data Structures & Algorithms
Group Assignment 8: Maps and Hash Tables

Prepared by: Omer Waqar (Ph.D., [Link]., SMIEEE)

*********** INSTRUCTIONS ***************


• Ensure that the outputs of programs match with the format specified in Question 1.

• Make sure to add clear screenshots of outputs of your programs in Question 1 and Ques-
tion 2.

• Question 3 is optional. Attempt it only if you wish to further practice Hash Table concepts.

• All submitted work must be your own (or your group’s) original work. Academic integrity
policies apply.

Question 1: Create an Unsorted Map


Gather all the required interfaces and classes (including the abstract classes) for implementation of
an Unsorted Map. Note that we studied about the required interfaces and classes during lecture.
After gathering the required interfaces and classes, complete the main method (given below) so
that this method is able to provide an output shown below.
1 public class UnsortedTableMapExample {
2 public static void main(String[] args) {
3 // Create a map using the interface type
4 Map<String, Integer> map = new UnsortedTableMap<>();
5
6 // Add entries to the map
7 [Link]("Alice", 25);
8 [Link]("Bob", 30);
9 //.
10 //.
11 //.
12 //****Your code should come here*****
13
14 // Use Iterator, for-each loop, and print keys and values
15 } // end main method
16 } // end class

1
The output should look like this:
Output:
Age of Alice: 25
Age of Bob: 30
Age of Charlie: 35
Removed Bob’s age: 30
Is the map empty? False
Entries in the map:
Key: Alice, Value: 25
Key: Charlie, Value: 35
Key: Eva, Value: 40
Size of the map: 3

Question 2: Hash Table with Separate Chaining


Gather all the required interfaces and classes (including the abstract classes) for implementation
of a Hash Table with separate chaining as a collision-resolution strategy. Note that we studied
about the required interfaces and classes during lecture. After gathering the required interfaces
and classes, modify the main method of question 1 so that this method is able to provide a same
output (the order of entries may change) as in question 1.

Question 3: [Optional] Hash Table with Separate Chaining and


Linear Probing
(i) Draw the 11-entry hash table that results from using the hash function, h(k) = (3k + 5) mod
11, to hash the keys 12, 44, 13, 88, 23, 94, 11, 39, 20, 16, and 5, assuming collisions are
handled by separate chaining.

(ii) Solve the problem (i) assuming collisions are handled by linear probing.

You might also like