Quiz 5 Worksheet on Object Oriented Programming II | CMSC 132, Quizzes of Computer Science

Material Type: Quiz; Class: OBJECT-ORIENTED PROG II; Subject: Computer Science; University: University of Maryland; Term: Unknown 1989;

Typology: Quizzes

Pre 2010

Uploaded on 07/29/2009

koofers-user-mrz
koofers-user-mrz 🇺🇸

10 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CMSC 132 Quiz 5 Worksheet
The fifth quiz of the course will be on Monday, Apr 27 during your lab (discussion) session. The following list
provides additional information about the quiz:
The quiz will be a written quiz (no computer).
Closed book, closed notes quiz.
Answers must be neat and legible. We recommend that you use pencil and eraser.
The following exercises cover the material to be included in this quiz. Solutions to these exercises will not be
provided, but you are welcome to discuss your solutions with TAs and instructors.
Graph Problem I
Use the following graph to answer the questions below.
1. Give a possible order in which the nodes of this graph could be visited in performing a Breadth
First Search (BFS) starting at vertex F. Pick nodes to visit using alphabetical order (when multiple
choices are possible).
2. Give a possible order in which the nodes of this graph could be visited in performing a Depth First
Search (DFS) starting at vertex F. Pick nodes to visit using alphabetical order (when multiple
choices are possible).
3. Apply Dijkstra’s algorithm using A as the starting (source) node. Indicate the cost and predecessor
for each node in the graph after processing 2 nodes ( A and another node). Remember to update
the appropriate table entries after processing the 2nd node (after it has been added to the set of
processed nodes). An empty table entry implies an infinite cost or no predecessor. Note: do not
simply fill in the entire table with the final costs and predecessors instead of showing the table at
the first two steps.
After processing 1 node:
Node
A
B
C
D
E
F
Cost
Predecessor
A
D
C
B
E
3
6
8
9
F
pf2

Partial preview of the text

Download Quiz 5 Worksheet on Object Oriented Programming II | CMSC 132 and more Quizzes Computer Science in PDF only on Docsity!

CMSC 132 Quiz 5 Worksheet

The fifth quiz of the course will be on Monday, Apr 27 during your lab (discussion) session. The following list provides additional information about the quiz:

 The quiz will be a written quiz (no computer).  Closed book, closed notes quiz.  Answers must be neat and legible. We recommend that you use pencil and eraser.

The following exercises cover the material to be included in this quiz. Solutions to these exercises will not be provided, but you are welcome to discuss your solutions with TAs and instructors.

Graph Problem I

Use the following graph to answer the questions below.

1. Give a possible order in which the nodes of this graph could be visited in performing a Breadth

First Search (BFS) starting at vertex F. Pick nodes to visit using alphabetical order (when multiple choices are possible).

2. Give a possible order in which the nodes of this graph could be visited in performing a Depth First

Search (DFS) starting at vertex F. Pick nodes to visit using alphabetical order (when multiple choices are possible).

3. Apply Dijkstra’s algorithm using A as the starting (source) node. Indicate the cost and predecessor

for each node in the graph after processing 2 nodes ( A and another node). Remember to update the appropriate table entries after processing the 2nd^ node (after it has been added to the set of processed nodes). An empty table entry implies an infinite cost or no predecessor. Note: do not simply fill in the entire table with the final costs and predecessors instead of showing the table at the first two steps.

After processing 1 node:

Node A^ B^ C^ D^ E^ F

Cost

Predecessor

A

D

C

B

E

F

After processing 2 nodes:

Node A B C D E F

Cost

Predecessor

Graph Problem II

Use the following graph for the questions below.

1. DFS/BFS

For each of the following exercises, specify the order nodes are visited when performing the appropriate traversal. Pick nodes to visit using alphabetical order (when multiple choices are possible).

a. Apply DFS with A as the start node. b. Apply DFS with C as the start node (assuming edges are undirected). c. Apply BFS with D as the start node. d. Apply BFS with F as the start node (assuming edges are undirected).

2. Single Source Shortest Path

For each of the following exercises, assume that all edges in the above graph are undirected.

a. Apply Dijkstra’s algorithm with A as the start node. List shortest path to F. b. Apply Dijkstra’s algorithm with B as the start node. List shortest path to F. c. Apply Dijkstra’s algorithm with E as the start node. List shortest path to C.

B

C D A F E 2