0% found this document useful (0 votes)
43 views1 page

Homework 5

This document provides the prompts for Homework 5 in CPSC 5210: Algorithm. It includes 5 questions asking students to provide pseudocode for algorithms to solve single-destination shortest path problems, illustrate count-sort, design a BFS algorithm for shortest paths in directed graphs, draw hash tables handling collisions with separate chaining, linear probing, and double hashing, and provide an algorithm and diagrams to find the second largest key in a red-black tree. Students must submit their answers in writing or using MS Word or Latex.

Uploaded by

Ngô Anh Tuấn
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views1 page

Homework 5

This document provides the prompts for Homework 5 in CPSC 5210: Algorithm. It includes 5 questions asking students to provide pseudocode for algorithms to solve single-destination shortest path problems, illustrate count-sort, design a BFS algorithm for shortest paths in directed graphs, draw hash tables handling collisions with separate chaining, linear probing, and double hashing, and provide an algorithm and diagrams to find the second largest key in a red-black tree. Students must submit their answers in writing or using MS Word or Latex.

Uploaded by

Ngô Anh Tuấn
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Homework 5 CPSC 5210: Algorithm

Both Hard-copy and Electronic Submissions are Acceptable. You can either
scan your hand-writing answer sheet, or generate the answer sheet using
MS-WORD or Latex.

Name: _______________________________;

1. (20 points) The single-destination shortest path problem for a directed graph is to find the
shortest path from every other vertex to a specified vertex destV. Give an efficient algorithm
(pseudo code) to solve the single-destination shortest paths problem.
2. (20 points) Illustrate the operation of COUNT-SORT on an array [6, 0, 2, 1, 3, 3, 5, 3, 2, 1]
(show your work)

3. (20 points) Design a BFS-based algorithm (pseudo code) for directed graph that computes
the shortest distance (or the least number of vertices in-between) from vertex srcU to vertex
destV.

4. (20 points) Consider a hash table of size 7 with hash function h(k)=k mod 7. Draw the table
that results after inserting, in the given order, the following values: 19, 26,13,48,17 with respect
to following three different scenario: (1) the collision is handled by separate chaining; (2) the
collision is handled by linear probing; (3) the collision is handled by double-hashing using a
second hash function: h* = 5 (k mod 5). (Notes: several techniques involved in this question
were not emphasized in the class, you have to master them via slides or check the document in
BlackBoard)

5. (20 points) Design an algorithm (pseudo code) that returns the SECOND largest key value of
a Black-Red Tree. In addition, you can use diagrams to demonstrate that your algorithm make
sense.

You might also like