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 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
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
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
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
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
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
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)
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
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
October 29, 2014
In-Class Exercise 3: Depth-First-Search
Instructor: Mehmet Koyutrk
u
Assume that we have run Depth-First-Search (DFS) on a directed graph G(V, E) and obtained
the following discovery and nishing times for each vertex
EECS 340: Algorithms
October 29, 2014
In-Class Exercise 3: Depth-First-Search
Instructor: Mehmet Koyutrk
u
Assume that we have run Depth-First-Search (DFS) on a directed graph G(V, E) and obtained
the following discovery and nishing times for each vertex
Example
EECS 340: Algorithms
Quiz 4: Depth-First-Search (DFS)
Solution
Name:
Consider any DFS run on a directed graph G = (V, E). Prove or disprove the following claim:
For any edge uv E, if there is a path from v to u in G, then uv cannot be a cross edge
November 3, 2014
EECS 340: Algorithms
Quiz 4: Depth-First-Search (DFS)
Solution
Name:
Let u and v be two vertices in a directed graph G(V, E). Prove or disprove the following claim:
If uv and vu are both in E, then in any run of DFS on G, exactly one of t
EECS 340: Algorithms & Data Structures
Fall 2014
Lecture Notes 1: Subset-Sum (Dynamic Programming)
Instructor: Mehmet Koyutrk
u
The Subset-Sum problem is dened as follows: Given a set S = cfw_s1 , s2 , ., sn of n positive
integers and a positive integer
Example
EECS 340: Algorithms
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