Review for Midterm Exam

Similar documents
CSci 231 Final Review

Implementing Algorithms

DESIGN AND ANALYSIS OF ALGORITHMS

managing an evolving set of connected components implementing a Union-Find data structure implementing Kruskal s algorithm

Thomas H. Cormen Charles E. Leiserson Ronald L. Rivest. Introduction to Algorithms

CISC 320 Midterm Exam

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

COMP 251 Winter 2017 Online quizzes with answers

Course Review for Finals. Cpt S 223 Fall 2008

Introduction to Algorithms Third Edition

END-TERM EXAMINATION

CPSC 320 Midterm #1. February 4, 2015

Review implementation of Stable Matching Survey of common running times. Turn in completed problem sets. Jan 18, 2019 Sprenkle - CSCI211

implementing the breadth-first search algorithm implementing the depth-first search algorithm

CS521 \ Notes for the Final Exam

COMPSCI 311: Introduction to Algorithms First Midterm Exam, October 3, 2018

Algorithms and Data Structures

CSCE f(n) = Θ(g(n)), if f(n) = O(g(n)) and f(n) = Ω(g(n)).

1. To reduce the probability of having any collisions to < 0.5 when hashing n keys, the table should have at least this number of elements.

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

Sankalchand Patel College of Engineering - Visnagar Department of Computer Engineering and Information Technology. Assignment

Design and Analysis of Algorithms - - Assessment

ECE250: Algorithms and Data Structures Final Review Course

Announcements. CSEP 521 Applied Algorithms. Announcements. Polynomial time efficiency. Definitions of efficiency 1/14/2013

PROGRAM EFFICIENCY & COMPLEXITY ANALYSIS

Virtual University of Pakistan

Data Structures and Algorithms

Introduction to Data Structure

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

Midterm 1 for CS 170

CS/ENGRD 2110 Object-Oriented Programming and Data Structures Spring 2012 Thorsten Joachims. Lecture 25: Review and Open Problems

Outline. Graphs. Divide and Conquer.

Department of Computer Applications. MCA 312: Design and Analysis of Algorithms. [Part I : Medium Answer Type Questions] UNIT I

CS 112 Final May 8, 2008 (Lightly edited for 2012 Practice) Name: BU ID: Instructions

CLASS: II YEAR / IV SEMESTER CSE CS 6402-DESIGN AND ANALYSIS OF ALGORITHM UNIT I INTRODUCTION

CS 112 Final May 8, 2008 (Lightly edited for 2011 Practice) Name: BU ID: Instructions GOOD LUCK!

Algorithms and Data Structures (INF1) Lecture 15/15 Hua Lu

Algorithm Analysis. Applied Algorithmics COMP526. Algorithm Analysis. Algorithm Analysis via experiments

Problem set 2. Problem 1. Problem 2. Problem 3. CS261, Winter Instructor: Ashish Goel.

Data Structures and Algorithm Analysis in C++

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

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

GRAPHS Lecture 19 CS2110 Spring 2013

Graph Algorithms (part 3 of CSC 282),

Graphs and Network Flows ISE 411. Lecture 7. Dr. Ted Ralphs

Final Exam in Algorithms and Data Structures 1 (1DL210)

CS1800 Discrete Structures Final Version B

Graph Algorithms (part 3 of CSC 282),

CSC2100-Data Structures

[ 11.2, 11.3, 11.4] Analysis of Algorithms. Complexity of Algorithms. 400 lecture note # Overview

Discrete Mathematics and Probability Theory Fall 2015 Rao Midterm 1

CSE 521: Design and Analysis of Algorithms I

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

Course Review. Cpt S 223 Fall 2009

The Algorithm Design Manual

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

CS583 Lecture 01. Jana Kosecka. some materials here are based on Profs. E. Demaine, D. Luebke A.Shehu, J-M. Lien and Prof. Wang s past lecture notes

Anany Levitin 3RD EDITION. Arup Kumar Bhattacharjee. mmmmm Analysis of Algorithms. Soumen Mukherjee. Introduction to TllG DCSISFI &

CSE 331 Introduction to Algorithm Analysis and Design. Sample Mid-term Exam-I: Fall 2018

Exam 3 Practice Problems

U.C. Berkeley CS170 : Algorithms, Fall 2013 Midterm 1 Professor: Satish Rao October 10, Midterm 1 Solutions

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

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

CSCE 321/3201 Analysis and Design of Algorithms. Prof. Amr Goneid. Fall 2016

CSE 431/531: Analysis of Algorithms. Greedy Algorithms. Lecturer: Shi Li. Department of Computer Science and Engineering University at Buffalo

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

asymptotic growth rate or order compare two functions, but ignore constant factors, small inputs

Your favorite blog : (popularly known as VIJAY JOTANI S BLOG..now in facebook.join ON FB VIJAY

Data Structures Lecture 8

4.1.2 Merge Sort Sorting Lower Bound Counting Sort Sorting in Practice Solving Problems by Sorting...

CS 6783 (Applied Algorithms) Lecture 5

INDIAN STATISTICAL INSTITUTE

CSE 431/531: Algorithm Analysis and Design (Spring 2018) Greedy Algorithms. Lecturer: Shi Li

( ) 1 B. 1. Suppose f x

Instructions. Definitions. Name: CMSC 341 Fall Question Points I. /12 II. /30 III. /10 IV. /12 V. /12 VI. /12 VII.

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

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

Review of course COMP-251B winter 2010

EECS Sample Midterm Exam

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

Course Name: B.Tech. 3 th Sem. No of hours allotted to complete the syllabi: 44 Hours No of hours allotted per week: 3 Hours. Planned.

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

Computational Discrete Mathematics

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?

Chapter 9 Graph Algorithms

R10 SET - 1. Code No: R II B. Tech I Semester, Supplementary Examinations, May

DATA STRUCTURES AND ALGORITHMS

Homework Assignment #3 Graph

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

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

Data Structures and Algorithms

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

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

Reference Sheet for CO142.2 Discrete Mathematics II

Copyright 2007 Pearson Addison-Wesley. All rights reserved. A. Levitin Introduction to the Design & Analysis of Algorithms, 2 nd ed., Ch.

Chapter 1 Introduction

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

15CS43: DESIGN AND ANALYSIS OF ALGORITHMS

Discrete Mathematics and Probability Theory Spring 2016 Rao and Walrand Midterm 1

1 Format. 2 Topics Covered. 2.1 Minimal Spanning Trees. 2.2 Union Find. 2.3 Greedy. CS 124 Quiz 2 Review 3/25/18

Transcription:

Review for Midterm Exam 1 Policies and Overview midterm exam policies overview of problems, algorithms, data structures overview of discrete mathematics 2 Sample Questions on the cost functions of algorithms the Gale-Shapley algorithm algorithms on graphs scheduling, sorting, and... CS 401/MCS 401 Lecture 11 Computer Algorithms I Jan Verschelde, 13 July 2018 Computer Algorithms I (CS 401/MCS 401) Review for Midterm Exam L-11 13 July 2018 1 / 23

Review for Midterm Exam 1 Policies and Overview midterm exam policies overview of problems, algorithms, data structures overview of discrete mathematics 2 Sample Questions on the cost functions of algorithms the Gale-Shapley algorithm algorithms on graphs scheduling, sorting, and... Computer Algorithms I (CS 401/MCS 401) Review for Midterm Exam L-11 13 July 2018 2 / 23

midterm exam policies The Midterm Exam happens on Monday 16 July, from 10AM till 11:40AM. Closed book. No computers or electronic devices allowed. The exam covers the first 9 lectures. This corresponds to the first five chapters in the textbook. Sections not explicitly covered in class will not be on the exam. There will not be a makeup Midterm Exam. You may skip the Midterm Exam. The 100 points transfer automatically to the Final exam. Computer Algorithms I (CS 401/MCS 401) Review for Midterm Exam L-11 13 July 2018 3 / 23

Review for Midterm Exam 1 Policies and Overview midterm exam policies overview of problems, algorithms, data structures overview of discrete mathematics 2 Sample Questions on the cost functions of algorithms the Gale-Shapley algorithm algorithms on graphs scheduling, sorting, and... Computer Algorithms I (CS 401/MCS 401) Review for Midterm Exam L-11 13 July 2018 4 / 23

overview of problems 1 stable marriage (L-1, L-3) 2 graph traversals (L-3, L-4) 3 connected components in graph (L-4, L-5, L-8) 4 testing bipartiteness (L-4) 5 ordering nodes in a directed acyclic graph (L-5) 6 scheduling requests on one or multiple resources (L-5, L-6) 7 optimal caching (L-6) 8 shortest paths in a graph (L-6) 9 spanning trees (L-7) 10 counting inversions (L-8) 11 closest pair of points (L-8) 12 convolutions (L-8, L-9) 13 matrix multiplication (L-9) Computer Algorithms I (CS 401/MCS 401) Review for Midterm Exam L-11 13 July 2018 5 / 23

overview of algorithms 1 Gale-Shapley algorithm (L-1, L-3) 2 breadth first search (L-3, L-4) 3 depth first search (L-3, L-4) 4 topological ordering (L-5) 5 interval scheduling (L-5) 6 interval partitioning (L-5) 7 earliest deadline first (L-6) 8 farthest in the future (L-6) 9 Dijkstra s algorithm (L-6) 10 Kruskal s algorithm (L-7) 11 Prim s algorithm (L-7) 12 reverse delete (L-7) 13 merge sort to count inversions (L-8) 14 closest pair of points (L-8) 15 Karatsuba s integer multiplication (L-8) 16 fast convolution (FFT) (L-9) 17 Strassen s method (L-9) Computer Algorithms I (CS 401/MCS 401) Review for Midterm Exam L-11 13 July 2018 6 / 23

overview of data structures 1 array and list (L-3) 2 queue and stack (L-4) 3 adjacency matrix representation of a graph (L-4) 4 edge list representation of a graph (L-4, L-5) 5 priority queue or heap (L-7) 6 union-find data structure (L-7) Computer Algorithms I (CS 401/MCS 401) Review for Midterm Exam L-11 13 July 2018 7 / 23

Review for Midterm Exam 1 Policies and Overview midterm exam policies overview of problems, algorithms, data structures overview of discrete mathematics 2 Sample Questions on the cost functions of algorithms the Gale-Shapley algorithm algorithms on graphs scheduling, sorting, and... Computer Algorithms I (CS 401/MCS 401) Review for Midterm Exam L-11 13 July 2018 8 / 23

overview of discrete mathematics 1 asymptotic bounds: big O, Ω, and Θ (L-2) 2 logarithmic, sublinear, linear, subquadratic, quadratic, cubic, polynomial, exponential growth (L-2) 3 transitivity and sum properties (L-2) 4 solving a recurrence by substitution (L-8) 5 solving a recurrence by unrolling (L-8) 6 the master method to solve recurrences (L-9) Computer Algorithms I (CS 401/MCS 401) Review for Midterm Exam L-11 13 July 2018 9 / 23

Review for Midterm Exam 1 Policies and Overview midterm exam policies overview of problems, algorithms, data structures overview of discrete mathematics 2 Sample Questions on the cost functions of algorithms the Gale-Shapley algorithm algorithms on graphs scheduling, sorting, and... Computer Algorithms I (CS 401/MCS 401) Review for Midterm Exam L-11 13 July 2018 10 / 23

1. derive and prove a cost function Consider the following problem: Input: U = [u i,j ], an n-by-n matrix, u i,i 0, b = (b 1, b 2,..., b n ), a vector of length n. Output: x = (x 1, x 2,..., x n ), a vector of length n, with x i = 1 b i u i,i n j=i+1 u i,j x j, i = n, n 1,..., 1. 1 Express the cost to compute x as a function of n. 2 Justify your cost function. Computer Algorithms I (CS 401/MCS 401) Review for Midterm Exam L-11 13 July 2018 11 / 23

2. compare in the O, Ω, Θ order Let f (n) = n 100n and g(n) = n 2. 1 Consider the statements: f (n) is O(g(n)), f (n) is Ω(g(n)), f (n) is Θ(g(n)). Which statement is true? For each statement, justify your answer. 2 Consider the statements: g(n) is O(f (n)), g(n) is Ω(f (n)), g(n) is Θ(f (n)). Which statement is true? For each statement, justify your answer. Computer Algorithms I (CS 401/MCS 401) Review for Midterm Exam L-11 13 July 2018 12 / 23

3. solving a recurrence Apply the master method to solve the following recurrences: 1 T (n) = 9T (n/3) + n 2 T (n) = T (2n/3) + 1 3 T (n) = 3T (n/4) + O(n log(n)) Computer Algorithms I (CS 401/MCS 401) Review for Midterm Exam L-11 13 July 2018 13 / 23

Review for Midterm Exam 1 Policies and Overview midterm exam policies overview of problems, algorithms, data structures overview of discrete mathematics 2 Sample Questions on the cost functions of algorithms the Gale-Shapley algorithm algorithms on graphs scheduling, sorting, and... Computer Algorithms I (CS 401/MCS 401) Review for Midterm Exam L-11 13 July 2018 14 / 23

4. the Gale-Shapley algorithm Consider 4 men {1, 2, 3, 4} and 4 women {1, 2, 3, 4}. Preferences for men Preferences for women 1 : 1 3 2 4 1 : 2 3 4 1 2 : 2 1 4 3 2 : 1 4 2 3 3 : 1 3 2 4 3 : 1 3 4 2 4 : 4 1 3 2 4 : 2 1 3 4 Preferences are listed from high to low for each man and woman. 1 Run the Gale-Shapley algorithm on the above input. Show all stages of the algorithm. 2 To demonstrate that the algorithm is efficient, a data structure is needed to determine the next woman a man proposes to. What is this data structure? Illustrate the use of this data structure on the above input. Computer Algorithms I (CS 401/MCS 401) Review for Midterm Exam L-11 13 July 2018 15 / 23

Review for Midterm Exam 1 Policies and Overview midterm exam policies overview of problems, algorithms, data structures overview of discrete mathematics 2 Sample Questions on the cost functions of algorithms the Gale-Shapley algorithm algorithms on graphs scheduling, sorting, and... Computer Algorithms I (CS 401/MCS 401) Review for Midterm Exam L-11 13 July 2018 16 / 23

5. topological ordering of a directed acyclic graph Consider the topological ordering in a DAG. 1 Let G be a graph with 6 vertices 0, 1, 2, 3, 4, 5 and edges E = { (0, 1), (0, 2), (0, 5), (1, 2), (3, 1), (2, 4), (2, 5), (3, 4), (4, 5) }. Illustrate the algorithm to order the vertices topologically on the above example. Draw all steps in the execution of the algorithm. 2 Is the solution of a topological ordering unique? Justify your answer. Computer Algorithms I (CS 401/MCS 401) Review for Midterm Exam L-11 13 July 2018 17 / 23

6. shortest paths in a graph Consider the shortest paths in a graph. 1 Let G be a weighted graph with 6 vertices 0, 1, 2, 3, 4, 5 with lengths l on edges (i, j) written as e (i,j) = l below: e (0,1) = 7, e (0,2) = 9, e (0,5) = 14, e (1,2) = 10, e (1,3) = 15, e (2,3) = 11, e (2,5) = 2, e (3,4) = 6, e (4,5) = 9. Compute the shortest paths originating at 0. Draw all steps in the execution of the algorithm. 2 Use the step wise execution of the algorithm above to illustrate the main argument in the correctness proof of the algorithm. In particular, if the set of explored vertices equals three, justify why the path to the fourth vertex in the path from 0 will be the shortest path from 0 to the fourth explored vertex. Computer Algorithms I (CS 401/MCS 401) Review for Midterm Exam L-11 13 July 2018 18 / 23

7. minimum spanning tree 1 Let G be a weighted graph with 7 vertices 0, 1, 2, 3, 4, 5, 6 with weights w on edges (i, j) written as e (i,j) = w below: e (0,1) = 4, e (0,3) = 1, e (1,2) = 10, e (1,3) = 7, e (1,4) = 5, e (2,4) = 2, e (3,4) = 9, e (3,5) = 3, e (4,5) = 8, e (4,6) = 6, e (5,6) = 11. Execute Kruskal s algorithm on the above example. Draw all steps in the execution of the algorithm. 2 Illustrate the evolution of the union-find data structure during the execution of Kruskal s algorithm on the above example. List the main arguments why using the union-find data structure leads to an O(m log(n)) running time for Kruskal s algorithm, for a graph with n vertices and m edges. Computer Algorithms I (CS 401/MCS 401) Review for Midterm Exam L-11 13 July 2018 19 / 23

Review for Midterm Exam 1 Policies and Overview midterm exam policies overview of problems, algorithms, data structures overview of discrete mathematics 2 Sample Questions on the cost functions of algorithms the Gale-Shapley algorithm algorithms on graphs scheduling, sorting, and... Computer Algorithms I (CS 401/MCS 401) Review for Midterm Exam L-11 13 July 2018 20 / 23

8. interval scheduling Let the tuples (1, 8), (2, 14), (10, 16), (3, 19), (17, 20), and (18, 21) represent the start and finish times of 6 requests for a resource. 1 Run the scheduling algorithm to minimize maximum lateness on these requests. Show all steps in the execution of the algorithm. 2 What is the exchange argument used to show optimality? Illustrate the exchange argument on an example. Computer Algorithms I (CS 401/MCS 401) Review for Midterm Exam L-11 13 July 2018 21 / 23

9. counting inversions Consider the sequence 8, 5, 2, 4, 6, 1, 3, 7. 1 Illustrate the algorithm to count the number of inversions on the above sequence. 2 Explain why the counting does not lead to more operations than the number of operations one needs for merge sort. Illustrate the key argument by referring to the illustration on the above sequence. Computer Algorithms I (CS 401/MCS 401) Review for Midterm Exam L-11 13 July 2018 22 / 23

10.... The list of review questions is just a sample... Computer Algorithms I (CS 401/MCS 401) Review for Midterm Exam L-11 13 July 2018 23 / 23