Final Exam
EECS 340: Algorithms & Data Structures
December 17, 2013
You have 180 minutes to answer all questions.
The exam is open book and notes.
Please read the questions carefully.
You can refer to algorithms/theorems/lemmas in the book by their na
Midterm Exam EECS 3:10: Algorithms & Data Structures October 1-5, 2014
You haVe 75 minutes to answer all questions.
The exam is open book and notes.
You can refer to algorithms / theorems / lemmas in the book by their name
as appropriate (8.9., by the Mas
EECS 340 Algorithms
2015 Spring Semester
Midterm
March 5, 2015
Write your name and CWRU id on your paper
The test is 75 minutes, 100 points
Open book, open notes, antennas off
1. Give a tight asymptotic run time analysis for the following
recursive functi
Midterm Exam
EECS 340: Algorithms & Data Structures
October 9, 2013
You have 75 minutes to answer all questions.
The exam is open book and notes.
You can refer to algorithms/theorems/lemmas in the book by their name
as appropriate (e.g., by the Master
Midterm Exam
EECS 340: Algorithms & Data Structures
October 9, 2013
You have 75 minutes to answer all questions.
The exam is open book and notes.
You can refer to algorithms/theorems/lemmas in the book by their name
as appropriate (e.g., by the Master
HW Assignment 5 Ex22.2-7
Ex22.3-5 Ex22.3-8
Exercise 22.2-7
We can use the graph G = (V, E) with each vertex represents a wrestler and each
edge represents a rivalry.
Thus, the graph contains n vertices and r edges (|V|=n, |E|=r).
The algorithm can be desi
EECS 340: Algorithms
Sample Quiz
Quiz 2: Asymptotic Notation
Name:
Solution
Let f (n) = O(nk ) where k is a positive constant. Prove that f (2n) = O(nk ).
Solution:
Since f (n) = O(nk ), we know that constants c, n0 > 0 such that
f (n) cnk
for n n0 .
Ther
EECS 340: Algorithms
September 8, 2014
Quiz 1: Loop Invariants
Name:
Solution
Consider the following procedure:
procedure WhatsThat(A, n)
1 r
2 for i = 1 to n do
3
if A[i] < r then
4
r A[i]
5 return r
Question (a): State the loop invariant for the for loo
EECS 340: Algorithms
Fall 2014
In-Class Exercise 1: Comparing Functions
Instructor: Mehmet Koyutrk
u
For each of the following pairs of functions, write down the asymptotic relation between f (n)
and g(n); i.e., if f (n) = x(g(n) where x cfw_o, , , then w
EECS 340: Algorithms
Fall 2014
In-Class Exercise 1: Comparing Functions
Instructor: Mehmet Koyutrk
u
For each of the following pairs of functions, write down the asymptotic relation between f (n)
and g(n); i.e., if f (n) = x(g(n) where x cfw_o, , , then w
Course Syllabus
Fall 2014
EECS 340: Algorithms
Instructor: Mehmet Koyut rk
u
1
Course Objectives
Computer Science is no more about computers than astronomy is about telescopes.
E. W. Dijkstra
This course provides an introduction to the design and analysi
EECS 340: Algorithms
Example
Quiz 5: Optimal Substructure
Name:
The rod cutting problem is dened as follows: We are given a rod of length n (where n is an integer)
and and array p[1.n] of prices such that p[i] is the price of a rod of length i. We would l
EECS 340: Algorithms
Example
Quiz 5: Optimal Substructure
Name:
Solution
The rod cutting problem is dened as follows: We are given a rod of length n (where n is an integer)
and and array p[1.n] of prices such that p[i] is the price of a rod of length i. W
EECS 340: Algorithms
Fall 2015
In-Class Exercise 1: Comparing Functions
Instructor: Mehmet Koyutrk
u
For each of the following pairs of functions, write down the asymptotic relation between f (n)
and g(n); i.e., if f (n) = x(g(n) where x cfw_o, , , write
Course Syllabus
Fall 2015
EECS 340: Algorithms
Instructor: Mehmet Koyut rk
u
1
Course Objectives
Computer Science is no more about computers than astronomy is about telescopes.
E. W. Dijkstra
This course provides an introduction to the design and analysi
EECS 340: Algorithms
September 2, 2015
Quiz 1(Solution): Loop Invariants
Name:
Consider the following procedure:
procedure WhatDoesItDo(A, n, v)
1 c0
2 for i 1 to n do
3
if A[i] = v then
4
cc+1
5 return c
(a) State the loop invariant for the for loop on l
EECS 340: Algorithms
Fall 2015
In-Class Exercise 1: Comparing Functions
Instructor: Mehmet Koyutrk
u
For each of the following pairs of functions, write down the asymptotic relation between f (n)
and g(n); i.e., if f (n) = x(g(n) where x cfw_o, , , write
EECS 340: Algorithms
Example Solution
Quiz 1: Loop Invariants
Name:
Solution
Consider the following procedure:
procedure NotSoEfficient(c)
1 xc
2 yc
3 while x > 0 do
4
y y+1
5
xx1
6 return y
(a) State the loop invariant for the while loop on line 3.
Loop
September 16, 2015
EECS 340: Algorithms
Quiz 2: Asymptotic Notation
Name:
Solution
Prove or disprove that O(n) + O( n) = O(n).
Solution:
The statement is true, as we prove below:
Consider any two positive functions f (n) O(n) and g(n) O( n). By denition o
EECS 340: Algorithms
Fall 2015
Quiz 2(Example): Substitution Method
Name:
Solution
Let T (n) = T (n/2) + 3T (n/8) + (n). Prove that T (n) = O(n).
Solution
Since T (n) = T (n/2) + 3T (n/8) + (n), we know that there exists a constant c > 0 such that T (n)
December 3, 2014
EECS 340: Algorithms
Quiz 6: Greedy Choice
Name:
Solution
We have n activities. Each activity requires ti time to complete and has deadline di . We would
like to schedule the activities to minimize the maximum delay in completing any acti
EECS 340: Algorithms
October 1, 2014
Quiz 3: Substitution Method
Name:
Solution
Let T (n) = T (n/2) + 3T (n/8) + (n). Prove that T (n) = O(n).
Solution:
Since T (n) = T (n/2) + 3T (n/8) + (n), we know that there exists a constant c > 0 such that T (n)
T
EECS 340: Algorithms
Sample Quiz
Quiz 2: Asymptotic Notation
Name:
Let f (n) = O(nk ) where k is a positive constant. Prove that f (2n) = O(nk ).
Proof is
Proof is
Proof is
Student
Grading Key
satisfactory:
sound, but not complete:
not satisfactory:
is ab