6 Pages

q2sol

Course: CS 2008, Fall 2009
School: Georgia Tech
Rating:
 
 
 
 
 

Word Count: 808

Document Preview

3510: Name: CS Design and Analysis of Algorithms Summer 2008 Quiz II Instructions: Please write your name in the space provided at the upper left corner of this page. This quiz has 5 questions on the following 5 pages. For each question, write your answer in the space provided for it. You may write on the back of a page if the space provided is not sufficient. GOOD LUCK! Question 1 2 3 4 5 Total Score 0...

Register Now

Unformatted Document Excerpt

Coursehero >> Georgia >> Georgia Tech >> CS 2008

Course Hero has millions of student submitted documents similar to the one
below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

Course Hero has millions of student submitted documents similar to the one below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.
3510: Name: CS Design and Analysis of Algorithms Summer 2008 Quiz II Instructions: Please write your name in the space provided at the upper left corner of this page. This quiz has 5 questions on the following 5 pages. For each question, write your answer in the space provided for it. You may write on the back of a page if the space provided is not sufficient. GOOD LUCK! Question 1 2 3 4 5 Total Score 0 Problem 1 If the input graph is given by its adjacency matrix, what would the running time of each of the following algorithms be? Briefly justify your answer. 1. Depth-First Search Answer: O(n2 ) 2. Kruskal's Algorithm Answer: O(n2 + m log n) 3. Bellman-Ford Algorithm Answer: O(n2 + nm) 4. Dijkstra's Algorithm Answer: O(n2 ) 5. Floyd-Warshall Algorithm Answer: O(n3 ) 1 Problem 2 Indicate whether the following statement is true or false: Let G be a connected, weighted, undirected graph and let T be a minimum spanning tree of G. If the weight of one edge in T is decreased and the weights of all other edges in G are unchanged, then T remains a minimum spanning tree of the resulting new graph. Justify your answer. Answer: The statement is true. Let w and w be the old and new weight functions respectively. Let e be the edge in T whose weight is decreased. Thus w (e) = w(e) - k for some k > 0, and w(e ) = w (e ) for each edge e = e. Let T be any other spanning tree of G. Since T is a MST of G with respect to the old weight function w, w(T ) w(T ). If e T , then w (T ) < w(T ) w(T ) = w (T ). If e T , then w (T ) = w(T ) - k w(T ) - k = w (T ). Thus T remains a MST after the weight change. 2 Problem 3 Suppose that we are given a weighted undirected graph G = (V, E), a source s V , a destination t V , and a subset W V of vertices, and want to find a shortest path from s to t that must go through at least one vertex in W . Design an efficient algorithm that solves the problem by only two applications of a given algorithm for single-source shortest paths. Show that your algorithm is correct. Solution: Since the graph is undirected, for every pair of vertices u and v, a shortest path from u to is v also a shortest path from v to u due to symmetry. It can be seen that the weight of a shortest path from s to v involving at least one vertex in w W , equals wW min {(s.w) + (t, w)} . Let SP be any given algorithm for single-source shortest paths. Then the following algorithm solves the problem with two applications of SP: 1. Run SP(G, s) (using s as the source). 2. Run SP(G, t) (using t as the source). 3. Find a vertex w0 W with the smallest value of (s.w0 ) + (t, w0 ). 4. Return the concatenation of the shortest path between s and w0 , and that between t and w0 . 3 Problem 4 Let G = (V, E) be a weighted directed graph whose all-pairs shortest paths have already been computed. Suppose that a new edge is added to G. Show how to update the all-pairs shortest paths in O(n2 ) time, where n = |V |. Solution: Suppose a new edge (x, y) is added. For each pair of vertices u, v, du,v min {du,v , du,x + w(x, y) + dy,v } . 4 Problem 5 In class we learned an algorithm for computing a longest common subsequence of two strings. Call this algorithm 2-LCS. Now suppose that we want to compute a longest common subsequence of three strings. Consider a greedy algorithm 3-LCS(x, y, z) that simply outputs 2-LCS(2-LCS(x, y), z). Does 3-LCS correctly compute a longest common ...

Find millions of documents on Course Hero - Study Guides, Lecture Notes, Reference Materials, Practice Exams and more. Course Hero has millions of course specific materials providing students with the best way to expand their education.

Below is a small sample set of documents:

Georgia Tech - CS - 3510
Name:CS 3510: Design and Analysis of Algorithms Summer 2008 Quiz IIInstructions: Please write your name in the space provided at the upper left corner of this page. This quiz has 5 questions on the following 5 pages. For each question, write your
Georgia Tech - CS - 7210
BZFlags Features, Design and Issues Topics covered in this presentationInstallation Game Design Architecture Some relevant files InstallationRequirements OpenGL 1.0+ libSDL 1.2+ libCURLBuilding from the source http:/my.bzflag.org/w
Georgia Tech - CS - 2008
Genetic Algorithm in Kernighan and Richie C/* * * * Genetics algorithm example taken from &quot;The Amateur Scientist&quot; column of * * Scientific American, July 1992, pages 114-116 by Rick L. Riolo. * * * * This version of genes.c is written in the K&amp;R ver
Georgia Tech - CS - 6390
Genetic Algorithm in Kernighan and Richie C/* * * * Genetics algorithm example taken from &quot;The Amateur Scientist&quot; column of * * Scientific American, July 1992, pages 114-116 by Rick L. Riolo. * * * * This version of genes.c is written in the K&amp;R ver
Georgia Tech - CS - 2008
SOFTWARE REUSE Using existing software artifacts during the construction of a new software system - Krueger Code (libraries, idioms); Designs (patterns, architectural styles) Problems Abstracting, parameterization, compiling from specification t
Georgia Tech - CS - 6330
SOFTWARE REUSE Using existing software artifacts during the construction of a new software system - Krueger Code (libraries, idioms); Designs (patterns, architectural styles) Problems Abstracting, parameterization, compiling from specification t
Georgia Tech - CS - 2008
SORT EXERCISE Sorting is a well-understood concept that is surprisingly hard to specify precisely For this exercise, try to formally specify a SORT routine that takes a vector of integer values as input and returns a sorted vector of integer values
Georgia Tech - CS - 6330
SORT EXERCISE Sorting is a well-understood concept that is surprisingly hard to specify precisely For this exercise, try to formally specify a SORT routine that takes a vector of integer values as input and returns a sorted vector of integer values
Georgia Tech - CS - 2008
GOAL The overarching goal is to satisfy your customer This is one definition of quality This means having confidence that what you build is what the customer wanted There are various approaches for raising confidence; none that provide any guara
Georgia Tech - CS - 6330
GOAL The overarching goal is to satisfy your customer This is one definition of quality This means having confidence that what you build is what the customer wanted There are various approaches for raising confidence; none that provide any guara
Georgia Tech - CS - 2008
RefactoringMartin Fowler. Refactoring / Improving the Design of Existing Code. Addison Wesley, 1999.RefactoringRefactoring is the process of changing a software system in such a way that it does not alter the external behavior of the code yet imp
Georgia Tech - CS - 6330
RefactoringMartin Fowler. Refactoring / Improving the Design of Existing Code. Addison Wesley, 1999.RefactoringRefactoring is the process of changing a software system in such a way that it does not alter the external behavior of the code yet imp
Georgia Tech - CS - 2008
MUTATION TESTING White-box, error-based testing technique Built-in adequacy criteria Tool support The goal of mutation testing is to build an adequate sets of tests Finding faults is a side-effectERROR-BASED TESTING Devise tests that mimic th
Georgia Tech - CS - 6330
MUTATION TESTING White-box, error-based testing technique Built-in adequacy criteria Tool support The goal of mutation testing is to build an adequate sets of tests Finding faults is a side-effectERROR-BASED TESTING Devise tests that mimic th
Georgia Tech - CS - 6330
RefactoringMartin Fowler. Refactoring / Improving the Design of Existing Code. Addison Wesley, 1999.RefactoringRefactoring is the process of changing a software system in such a way that it does not alter the external behavior of the code yet imp
Georgia Tech - CS - 6330
What are Application Generators? They generate programs from high-level specifications Can also generate documentation and test data They have proven successful when they are confined to a limited domain (application area) This area used to be c
Georgia Tech - CS - 2008
Domain Engineering Domain Engineering is the activity of collecting, organizing, and storing past experience in building systems or parts of systems in a particular domain in the form of reusable assets (i.e., reusable work products), as well as pro
Georgia Tech - CS - 6330
Domain Engineering Domain Engineering is the activity of collecting, organizing, and storing past experience in building systems or parts of systems in a particular domain in the form of reusable assets (i.e., reusable work products), as well as pro
Georgia Tech - CS - 2008
ProductLineMetaprogramming (ExamplesfromCzarneckiandEisenecker) Metaprogramming,specificallyC+templates, canbeusedtobuildproductlinegenerators Thatis,theusercanspecifythevaluesfor opDons,andtheC+preprocessorwill automaDcallyconstructtheappropri
Georgia Tech - CS - 6330
ProductLineMetaprogramming (ExamplesfromCzarneckiandEisenecker) Metaprogramming,specificallyC+templates, canbeusedtobuildproductlinegenerators Thatis,theusercanspecifythevaluesfor opDons,andtheC+preprocessorwill automaDcallyconstructtheappropri
Georgia Tech - CS - 2008
Software MaintenanceThe process of modifying existing operational software while leaving its primary function intact - Barry BoehmThe Maintenance Problem 60-80% of total software cost is spent after delivery; 50% of total programmer time Many as
Georgia Tech - CS - 6330
Software MaintenanceThe process of modifying existing operational software while leaving its primary function intact - Barry BoehmThe Maintenance Problem 60-80% of total software cost is spent after delivery; 50% of total programmer time Many as
Georgia Tech - CS - 2008
Variation In support of abstraction and reuse, programming languages, as well as modeling notations, offer a variety of mechanisms to support variation The most obvious such mechanism is parameterizationthe ability to specify replaceable values in
Georgia Tech - CS - 6330
Variation In support of abstraction and reuse, programming languages, as well as modeling notations, offer a variety of mechanisms to support variation The most obvious such mechanism is parameterizationthe ability to specify replaceable values in
Georgia Tech - CS - 2008
Unit Testing Execution of source code by the original developer to verify correctness and nonfunctional properties The Extreme Programming community uses the XUnit framework to support unit testing Where X = {S, C+, or J} www.extremeprogramming.o
Georgia Tech - CS - 6330
Unit Testing Execution of source code by the original developer to verify correctness and nonfunctional properties The Extreme Programming community uses the XUnit framework to support unit testing Where X = {S, C+, or J} www.extremeprogramming.o
Georgia Tech - CS - 6330
JUnit JUnit is an object-oriented framework whose application domain is unit testing Define and run test; collect statistics Cook's Tour: literate program at the design level Literate programs (Knuth) present documentation along with code Patte
Georgia Tech - CS - 2008
Inheritance in C+ C+ supports inheritance-the ability of one program entity (class) to be defined in terms of another The derived class is said to inherit from the base class Defined features includes data members and member functions; definition
Georgia Tech - CS - 6330
Inheritance in C+ C+ supports inheritance-the ability of one program entity (class) to be defined in terms of another The derived class is said to inherit from the base class Defined features includes data members and member functions; definition
Georgia Tech - CS - 6330
Exercise( 1) ( 2) C ( 3) ( 4) ( 5) ( 6) ( 7) ( 8) ( 9) (10) (11) (12) (13) DOUBLE PRECISION FUNCTION SIN(X, E) THIS DECLARATION COMPUTES SIN(X)TO ACCURACY E DOUBLE PRECISION E,TERM,SUM REAL X TERM=X .LT. is less than * is exponentiation DO 20 I=3
Georgia Tech - CS - 2008
Object-Oriented Frameworks Domain-specific design reuse mechanism Reuse by subclassing Contrast with domain-specific languages and application generators Reuse by specification and generation Contrast with metaprogramming Reuse by instantiati