CSIS 0250B Design and Analysis of Algorithms Assignment 1 Due: 10:30 AM, Feb 11, 2009 Warm-up (no need to turn in) 1. Show how you would modify depth ﬁrst search to report a cycle of a given undirected graph, if it exists. The running time of your algorithm should be O ( m + n ) for a graph with n nodes and m edges. 2. The following algorithm attempts to detect whether an undirected graph contains a cycle: Sum the number of entries in the adjacent lists of all vertices. If the sum is at least twice the number of vertices, report that the graphs contains a cycle. Is this algorithm correct? 3. You are given an array of n elements. Some of the elements are duplicates. Given an O ( n log n ) time algorithm to remove all duplicates from the array. 4. Claim: Let G be a graph on n nodes, where n is an even number. If every node of G has degree at least n/2, then G is connected. Is the claim true or false? Problems
This is the end of the preview. Sign up
access the rest of the document.