This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: COMP 271 Design and Analysis of Algorithms 2004 Fall Semester Question Bank 2 Solving these questions will give you good practice for the midterm. Some of these ques tions (or similar ones) will definitely appear on your exam! Note that you do not have to submit answers to these questions for grading. Your TAs will discuss answers to selected questions in the tutorials. 1 Basic Graph Problems 1. Given an undirected graph G = ( V, E ), recall that the complement , G , is a graph ( V, E ′ ) such that for all u negationslash = v , { u, v } ∈ E ′ if and only if { u, v } / ∈ E . Prove that either G or G is connected. 2. When a vertex and its incident edges are removed from a tree, a collection of subtrees remains. Design a lineartime algorithm that, given a tree with n vertices, finds a vertex whose removal leaves no subtree with more than n/ 2 vertices. 2 BreadthFirst Search and DepthFirst Search 1. The adjacency list representation of a graph G , which has 7 vertices and 10 edges, is: a : → d, e, b, g b : → e, c, a c : → f, e, b, d d : → c, a, f e : → a, c, b f : → d, c g : → a a d e b c f g (a) Show the tree produced by depthfirst search when it is run on the graph G , using vertex a as the source. You must use the adjacency list representation given above. (Recall that the DFS tree can depend on the order of vertices in the adjacency lists; for this problem you are required to use the adjacency lists as given above.) 1 (b) In the DFS tree of item (a), show the edges of the graph...
View
Full
Document
This note was uploaded on 10/18/2009 for the course COMP 271 taught by Professor Arya during the Spring '07 term at HKUST.
 Spring '07
 ARYA
 Algorithms

Click to edit the document details