Computer Science 170 - Fall 1998 - Papadimitriou - Midterm 1

Computer Science 170 - Fall 1998 - Papadimitriou - Midterm...

This preview shows pages 1–3. Sign up to view the full content.

CS 170, Midterm 1, Fall 1998 CS 170, Fall 1998 Midterm 1 Problem #1 1. (15 points) What are the strongly connected components of the directed graph shown below? (Just circle them). Perform depth-first search on the graph shown above. For each vertex show the pre-order and post- order numbers, and label each edge with T, F, B, C depending on whether it is a tree, forward, back or cross edge. (As always, when in DFS we have a choice, we always select the alphabetically first vertex.) Can you add an edge to this graph to make it strongly connected? Problem #2 file:///C|/Documents%20and%20Settings/Jason%20Rafte. ..20Fall%201998%20-%20Papadimitriou%20-%20Mid%201.htm (1 of 5)1/27/2007 5:33:00 PM

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
CS 170, Midterm 1, Fall 1998 2. (15 points) We are given a tree T = (V,E) rooted at vertex r is an element of V. Recall that vertex u is an ancestor of vertex v in the rooted tree, if the path from r to v in the tree goes through u. We wish to preprocess the tree by associating numbers with the vertices, so that queries of the form "is u an ancestor of v?" can be answered in constant time. The preprocessing should take linear time. (Hint: Think depth-first search.)
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 5

Computer Science 170 - Fall 1998 - Papadimitriou - Midterm...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online