Docsity

CMSC 132 Quiz 2 Worksheet: DFS, BFS, and Dijkstra's Algorithm - Prof. Nelson Padua-Perez, Quizzes of Computer Science

Toggle sidebar
bg1
CMSC 132 Quiz 2 Worksheet
The next quiz of the course will be on Wednesday, April 19 during your lab (discussion) session.
The following list provides more 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
during office hours.
Exercises
Using the following graph answers the questions that follow. For BFS and DFS pick vertices to
process using alphabetical order.
1. DFS/BFS
For each of the following exercises, specify the nodes visited after performing the appropriate
traversal. When several node choices are available, use alphabetical order to choose a node
to process.
a. Run DFS with A as the start vertex.
b. Run BFS with D as the start vertex.
B
C
D
A
F
E
2
2
1
4
4
3
5
2
2
9
8
pf2

Partial preview of the text

Download CMSC 132 Quiz 2 Worksheet: DFS, BFS, and Dijkstra's Algorithm - Prof. Nelson Padua-Perez and more Quizzes Computer Science in PDF only on Docsity!

CMSC 132 Quiz 2 Worksheet

The next quiz of the course will be on Wednesday, April 19 during your lab (discussion) session. The following list provides more 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 during office hours.

Exercises

Using the following graph answers the questions that follow. For BFS and DFS pick vertices to process using alphabetical order.

1. DFS/BFS

For each of the following exercises, specify the nodes visited after performing the appropriate traversal. When several node choices are available, use alphabetical order to choose a node to process.

a. Run DFS with A as the start vertex. b. Run BFS with D as the start vertex.

B

C D A F E 2

2. Dijkstra’s Algorithm

a. Run Dijkstra’s algorithm using A as the start vertex. Indicate the cost and predecessor

for each node in the graph after you completing the algorithm.

b. Run Dijkstra’s algorithm using B as the start vertex. Indicate the cost and predecessor for

each node in the graph, after four nodes have been added to the set of processed nodes (set S in the lecture slides).