0% found this document useful (0 votes)
20 views

Homework3

Uploaded by

trueessentially
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

Homework3

Uploaded by

trueessentially
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Homework 3

CMSC 341 - Section 4 & 5 - Fall 2024


Due Date December 10, 2024, 11:59 PM
Total: 60 (3 questions) + 25 (Extra Credit)

Question 1 (30):
Given a hash table with m=11 entries and the following hash function h1 and step function h2:
h1(key) = key mod m
h2(key) = {key mod (m-1)} + 1

Insert the keys {22, 1, 13, 11, 24, 33, 18, 42, 31} in the given order (from left to right) to the
hash table using each of the following hash methods:

a. Chaining with h1  h(k) = h1(k)

b. Linear-Probing with h1  h(k,i) = (h1(k)+i) mod m


c. Double-Hashing with h1 as the hash function and h2 as the step function

 h(k,i) = (h1(k) + ih2(k)) mod m

Question 2 (10):
Here is the array format of a heap: {100, 3, 36, 1, 2, 7, 19, 25, 17}
Apply Heapify rules to convert this array into a Max Heap. Show all the steps for full credit.
Question 3 (20):
Perform BFS and DFS traversal on this graph below starting from node A. At each step, show
the status of the queue and the result variable for the BFS traversal. Similarly, show the status
of the stack and the result variable at each step for the DFS traversal. Responses not showing all
the steps will not receive full credit.

Question 4: (20 + 5 = 25 points: Extra Credit)


Calculate the shortest path following the Dijkstra’s algorithm from vertex “a” for the following
graph to all available vertices. Show the complete table for full credit. Compute the shortest
path from “a” to “f” from the table.

You might also like