CMSC 132 Quiz 5 Worksheet: Threads and Minimum Spanning Trees, Study notes of Computer Science

Information about quiz 5 for cmsc 132, including the quiz date, format, and covered topics. The topics include threading in java and minimum spanning trees using prim's and kruskal's algorithms. Exercises for each topic, but no solutions are given. University students are encouraged to discuss their answers with tas and instructors during office hours.

Typology: Study notes

Pre 2010

Uploaded on 02/13/2009

koofers-user-d8b
koofers-user-d8b 🇺🇸

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 next quiz of the course will be on Wednesday, November 15 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.
Thread/Synchronization
1.
What are two advantages to multi-threading?
2.
What are two disadvantages to using multi-threading?
3.
What are two ways to create threads in Java?
4.
What is a daemon thread?
5.
What is a deadlock? How can you avoid it?
6.
What is a data race? How can you avoid it?
7.
Write a Java program called LinePrinter that starts a new thread for each line printed.
8.
Write a Java program called ParallelQueue that allows multiple threads to add and remove items
to a queue without data races or deadlock.
Minimum Spanning Trees
Using the following graph answers the questions that follow.
9.
Minimum Spanning Tree (Using Prim’s Algorithm)
When several node choices are available, use alp habetical order to choose a node to process.
b
c
d
a
e
f
2
1
4
2
3
7
6
5
pf2

Partial preview of the text

Download CMSC 132 Quiz 5 Worksheet: Threads and Minimum Spanning Trees and more Study notes Computer Science in PDF only on Docsity!

CMSC 132 Quiz 5 Worksheet

The next quiz of the course will be on Wednesday, November 15 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.

Thread/Synchronization

1. What are two advantages to multi-threading?

2. What are two disadvantages to using multi-threading?

3. What are two ways to create threads in Java?

4. What is a daemon thread?

5. What is a deadlock? How can you avoid it?

6. What is a data race? How can you avoid it?

7. Write a Java program called LinePrinter that starts a new thread for each line printed.

8. Write a Java program called ParallelQueue that allows multiple threads to add and remove items

to a queue without data races or deadlock.

Minimum Spanning Trees

Using the following graph answers the questions that follow.

9. Minimum Spanning Tree (Using Prim’s Algorithm)

When several node choices are available, use alphabetical order to choose a node to process.

b

c d a e f 2

a. Generate the minimum spanning tree for the above graph using Prim’s algorithm. Use a as the start vertex.

b. Run Prim’s algorithm using b as the start vertex. Indicate the cost and predecessor for each node in the graph, after three nodes have been added to the set of processed nodes (set S in the lecture slides). You don’t need to draw a tree.

10. Minimum Spanning Tree (Using Kruskal’s Algorithm)

a. Generate the minimum spanning tree for the above graph using Kruskal’s algorithm.

b. Run Kruskal’s algorithm in the above graph and draw the graph we will have after only four edges have been processed.