mock1solution - Graphs 1. From Hilfinger Fall 2007: Suppose...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Graphs 1. From Hilfinger Fall 2007: Suppose you have some weighted undirected graph. This graph has three nodes of interest. In one node, there is a cat. In another there is a rat. In a third, there is a mousehole. Each "turn", the cat and mouse can move to a node connected to one they are currently on. If the mouse reaches the mousehole before the cat can, then he wins. If the cat reaches it first or they tie, the cat wins. Describe how you would determine the winner in 2 sentences or less. Dijkstra's Algorithm 2. From Shewchuk Spring 2004: a. How long does it take to determine if an undirected graph contains a vertex that is connected to no other vertices [i] if you use an adjacency matrix; [ii] if you use adjacency lists. i: v^2, since you need to look at all the entries of the matrix ii: v. You walk down this list, and if any of them is null, you have found such a vertex. A -> Neighbors of A B -> Neighbors of B. C -> Null. b. An undirected graph contains a "cycle" (i.e., loop) if there are two different simple paths by which we can get from one vertex to another. Using your favorite graphpaths by which we can get from one vertex to another....
View Full Document

This note was uploaded on 09/23/2008 for the course CS 61B taught by Professor Canny during the Summer '01 term at University of California, Berkeley.

Page1 / 4

mock1solution - Graphs 1. From Hilfinger Fall 2007: Suppose...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online