Problem 1. Which of the following is true of functions =100 +log and = + log? Problem 2. Which of the following is true of functions = 2 and =3?

Similar documents
Chapter 9 Graph Algorithms

CSci 231 Final Review

CS490 Quiz 1. This is the written part of Quiz 1. The quiz is closed book; in particular, no notes, calculators and cell phones are allowed.

Graph Algorithms (part 3 of CSC 282),

CIS 121 Data Structures and Algorithms Midterm 3 Review Solution Sketches Fall 2018

Chapter 9 Graph Algorithms

CMSC351 - Fall 2014, Final Exam

11/22/2016. Chapter 9 Graph Algorithms. Introduction. Definitions. Definitions. Definitions. Definitions

Chapter 9 Graph Algorithms

Graph Algorithms (part 3 of CSC 282),

Exam 3 Practice Problems

Problem Score Maximum MC 34 (25/17) = 50 Total 100

Solving problems on graph algorithms

( ) + n. ( ) = n "1) + n. ( ) = T n 2. ( ) = 2T n 2. ( ) = T( n 2 ) +1

CS521 \ Notes for the Final Exam

D. Θ nlogn ( ) D. Ο. ). Which of the following is not necessarily true? . Which of the following cannot be shown as an improvement? D.

Two hours UNIVERSITY OF MANCHESTER SCHOOL OF COMPUTER SCIENCE. Date: Thursday 1st June 2017 Time: 14:00-16:00

COMP 251 Winter 2017 Online quizzes with answers

END-TERM EXAMINATION

n 2 ( ) ( ) + n is in Θ n logn

Algorithm Analysis Graph algorithm. Chung-Ang University, Jaesung Lee

& ( D. " mnp ' ( ) n 3. n 2. ( ) C. " n

Minimum Spanning Trees

n 2 ( ) ( ) Ο f ( n) ( ) Ω B. n logn Ο

INDIAN STATISTICAL INSTITUTE

NP-complete Reductions

) $ f ( n) " %( g( n)

University of New Mexico Department of Computer Science. Final Examination. CS 362 Data Structures and Algorithms Spring, 2006

( D. Θ n. ( ) f n ( ) D. Ο%

UNIT Name the different ways of representing a graph? a.adjacencymatrix b. Adjacency list

from notes written mostly by Dr. Carla Savage: All Rights Reserved

Final Examination CSE 100 UCSD (Practice)

n 2 C. Θ n ( ) Ο f ( n) B. n 2 Ω( n logn)

Algorithms. All-Pairs Shortest Paths. Dong Kyue Kim Hanyang University

2. True or false: even though BFS and DFS have the same space complexity, they do not always have the same worst case asymptotic time complexity.

Graph Algorithms. Chapter 22. CPTR 430 Algorithms Graph Algorithms 1

( ) n 3. n 2 ( ) D. Ο

Dr. Amotz Bar-Noy s Compendium of Algorithms Problems. Problems, Hints, and Solutions

Algorithm Computation of a Single Source Shortest Path in a Directed Graph. (SSSP algorithm)

Data Structures Brett Bernstein

Lecture 3: Graphs and flows

( ) ( ) C. " 1 n. ( ) $ f n. ( ) B. " log( n! ) ( ) and that you already know ( ) ( ) " % g( n) ( ) " #&

DESIGN AND ANALYSIS OF ALGORITHMS

ALGORITHMS EXAMINATION Department of Computer Science New York University December 17, 2007

Contents. CS 124 Final Exam Practice Problem 5/6/17. 1 Format and Logistics 2

Chapter 9. Greedy Technique. Copyright 2007 Pearson Addison-Wesley. All rights reserved.

CS170 Discussion Section 4: 9/18

DESIGN AND ANALYSIS OF ALGORITHMS GREEDY METHOD

Student number: Datenstrukturen & Algorithmen page 1

Lecture 10 Graph algorithms: testing graph properties

( ) D. Θ ( ) ( ) Ο f ( n) ( ) Ω. C. T n C. Θ. B. n logn Ο

Graphs. Part II: SP and MST. Laura Toma Algorithms (csci2200), Bowdoin College

Recitation 13. Minimum Spanning Trees Announcements. SegmentLab has been released, and is due Friday, November 17. It s worth 135 points.

CS 170 Second Midterm ANSWERS 7 April NAME (1 pt): SID (1 pt): TA (1 pt): Name of Neighbor to your left (1 pt):

CMPSCI 311: Introduction to Algorithms Practice Final Exam

Total Score /1 /20 /41 /15 /23 Grader

CS 4407 Algorithms Lecture 5: Graphs an Introduction

Homework 2. Sample Solution. Due Date: Thursday, May 31, 11:59 pm

( ). Which of ( ) ( ) " #& ( ) " # g( n) ( ) " # f ( n) Test 1

CS 125 Section #6 Graph Traversal and Linear Programs 10/13/14

Pred 8 1. Dist. Pred

Multiple Choice. Write your answer to the LEFT of each problem. 3 points each

CS/COE 1501 cs.pitt.edu/~bill/1501/ Graphs

L.J. Institute of Engineering & Technology Semester: VIII (2016)

Algorithm Design (8) Graph Algorithms 1/2

CS61B, Fall 2015 Final Examination (with corrections) P. N. Hilfinger

Graph Representation DFS BFS Dijkstra A* Search Bellman-Ford Floyd-Warshall Iterative? Non-iterative? MST Flow Edmond-Karp

RBGL: R interface to boost graph library

logn D. Θ C. Θ n 2 ( ) ( ) f n B. nlogn Ο n2 n 2 D. Ο & % ( C. Θ # ( D. Θ n ( ) Ω f ( n)

Sample Solutions to Homework #4

Shortest path problems

How to Do Word Problems. Study of Integers

- Logic and Algorithms - Graph Algorithms

22.3 Depth First Search

1 Shortest Paths. 1.1 Breadth First Search (BFS) CS 124 Section #3 Shortest Paths and MSTs 2/13/2018

1. [1 pt] What is the solution to the recurrence T(n) = 2T(n-1) + 1, T(1) = 1

Quiz 2 CS 3510 October 22, 2004

Direct Addressing Hash table: Collision resolution how handle collisions Hash Functions:

Review for Midterm Exam

CS200: Graphs. Rosen Ch , 9.6, Walls and Mirrors Ch. 14

GRAPHS Lecture 17 CS2110 Spring 2014

DO NOT RE-DISTRIBUTE THIS SOLUTION FILE

CS1800 Discrete Structures Final Version B

Module 2: NETWORKS AND DECISION MATHEMATICS

Introduction to Algorithms. Lecture 24. Prof. Patrick Jaillet

Algorithms (IX) Guoqiang Li. School of Software, Shanghai Jiao Tong University

UNIT 5 GRAPH. Application of Graph Structure in real world:- Graph Terminologies:

Index. stack-based, 400 A* algorithm, 325

CSE 100 Minimum Spanning Trees Prim s and Kruskal

CSE Winter 2015 Quiz 1 Solutions

Exercise 1. D-ary Tree

End-Term Examination Second Semester [MCA] MAY-JUNE 2006

Further Mathematics 2016 Module 2: NETWORKS AND DECISION MATHEMATICS Chapter 9 Undirected Graphs and Networks

9. The expected time for insertion sort for n keys is in which set? (All n! input permutations are equally likely.)

(Dijkstra s Algorithm) Consider the following positively weighted undirected graph for the problems below: 8 7 b c d h g f

Test 1 Last 4 Digits of Mav ID # Multiple Choice. Write your answer to the LEFT of each problem. 2 points each t 1

Dynamic-Programming algorithms for shortest path problems: Bellman-Ford (for singlesource) and Floyd-Warshall (for all-pairs).

Algorithm Design, Anal. & Imp., Homework 4 Solution

Two hours UNIVERSITY OF MANCHESTER SCHOOL OF COMPUTER SCIENCE. Date: Thursday 27th January 2011 Time: 14:00-16:00

Best known solution time is Ω(V!) Check every permutation of vertices to see if there is a graph edge between adjacent vertices

Transcription:

Multiple-choice Problems: Problem 1. Which of the following is true of functions =100+log and =+log? a) = b) =Ω c) =Θ d) All of the above e) None of the above Problem 2. Which of the following is true of functions =2 and =3? a) = b) =Ω c) =Θ d) All of the above e) None of the above Problem 3. Which of the following statements are true of collision resolution with linear probing for universal hash function h with constant load factor =, where n is the number of items to hash, and m is the size of the hash table? a) Operations Insert and Search can take average 1 time. b) The Delete operation may not take average 1 time. c) For all keys and, where, [h=h] 1 d) All of (a),(b) and (c) e) None of (a), (b) and (c) Problem 4. Using which of the following algorithm you can check whether a given graph is connected or not? a) DFS b) BFS c) Dijkstra d) (a) and (b) e) All of the above Problem 5. For dense graphs with Ω(n 2 ) weighted edges what is the best running time for an all-pairs shortest-paths algorithm that you have seen in the class? a) O(n 2 log n) b) O(n 3 ) c) O(n) d) O(n 3 log n) e) O(n 2 ) Problem 6. Let G be a Directed Acyclic Graph (DAG) with 22 vertices. What is the maximum possible number of vertices with both in-degree and out-degree one in G? a) 1 b) 2 c) 20 d) 21 e) 22

Problem 7. Consider the graph below which is represented by its adjacency matrix A. Here A[i,j] is the weight of the edge from vertex i to vertex j. If we run Floyd-Warshall algorithm on this graph what would be the sum of the lengths of the shortest paths of the pairs (1,5), (4,5), (5,1), and (3,1)? 0 5 9 4 1 6 5 0 5 1 8 6 9 5 0 7 5 3 4 1 7 0 9 9 1 8 5 9 0 4 6 6 3 9 4 0 a) 10 b) 11 c) 12 d) 13 e) 14 Problem 8. What is the length of the Minimum Spanning Tree (MST) in the graph of Problem 7? a) 8 b) 9 c) 10 d) 11 e) 13

Regular Problems (you should always PROVE THE CORRECTNESS of your solutions): Problem 9. Given a sequence of (not necessary positive) integers,,, find a subsequence,,, (of consecutive elements) such that the sum of the numbers in it is even and maximum over all subsequences of consecutive elements with an even sum of elements. For example if the sequence is 5, 1,4, 10,3,3,3, the maximum even consecutive subsequence is 5, 1,4. The running time of your algorithm should be in. We say a subsequence of consecutive elements is even if the sum of elements in it is even, otherwise we say it is odd. Define as the maximum sum of even subsequences ending at. Similarly, define as the maximum sum of odd subsequences ending at. Clearly the answer to the problem is max. We only need to show how we can compute s and s in. One can easily show that the following recursive formula holds, which would directly give us the desired algorithm: and are easily computable. For 2: If is even => =max {0, + } and = + If is odd => =max {0, + } and = +

Problem 10. Given 1 US dollar, the set of currencies, and exchange rates between each pair of currencies, design an algorithm which decides whether we can change our 1 US dollar to more than 1 US dollar by just exchanging our money. Note that if we have two currencies u and v with exchange rate r from u to v, it means that x units of money in u are worth r x units of money in v for any x R. (Hint: use the problem of finding a negative cycle in a graph). We make a weighted directed graph such that has a negative cycle iff we can change our 1 US dollar to more than 1 US dollar. We put a vertex in for each currency. For every exchange ratio from currency to currency, we put a directed edge of weight lg from to and we put a directed edge of weight lg from to. Now consider a cycle in exchanging the currencies. If the cycle is,,,, and we have 1 unit of, then we will have units of by exchanging our money from to, then from to and so on until we change our money back to from ( is the exchange ratio from to ). On the other hand, the length of this cycle in graph, is lg lg lg = lg. Finally, we know that >1 if and only if lg <0 and thus we can change our money from 1 dollar to more than one dollar iff has a negative cycle.

Problem 11. An independent set in an undirected graph G is a set S of vertices such that between any two vertices of S there is no edge in G. Given an undirected graph G and an integer k, the independent set problem asks whether there is an independent set of size at least k in graph G. Prove the clique problem is polynomially reducible to the independent set problem. Given instance of CLIQUE =,, construct graph =,. There is a clique of size in G iff there is an I.S. of size in.

Problem 12. Explain Dijkstra s algorithm in details and prove its correctness. Look at Section 7.4 of the book.