Analysis of Algorithms
CS 477/677
Instructor: Monica
Nicolescu
Lecture 12
Midterm Exam
Wednesday, March 12 in classroom
75 minutes
Exam structure:
short questions on the topics discussed in class
TRUE
CS 477/677 Analysis of Algorithms
Homework 1
Due September 8, 2015
1. (U & G-required) [30 points] Arrange the following list of functions in ascending
order of growth rate. That is, if function g(n)
Analysis of Algorithms
CS 477/677
Instructor: Monica
Nicolescu
Lecture 3
Recurrent Algorithms
BINARY SEARCH
for an ordered array A, finds if x is in the array A[lohi]
Alg.: BINARY-SEARCH (A, lo, hi, x
Analysis of Algorithms
CS 477/677
Instructor: Monica
Nicolescu
Lecture 6
Merge Sort Approach
To sort an array A[p.r]:
Divide
Divide the n-element sequence to be sorted into two
subsequences of n/2 ele
Analysis of Algorithms
CS 477/677
Instructor: Monica
Nicolescu
Lecture 1
General Information
Instructor: Dr. Monica Nicolescu
E-mail:
[email protected]
Office hours: Monday: 11am-noon, 3:45-4:45pm
We
Analysis of Algorithms
CS 477/677
Instructor: Monica
Nicolescu
Lecture 2
Algorithm Analysis
The amount of resources used by the algorithm
Running time:
Space
Computational time
The number of primitive
Analysis of Algorithms
CS 477/677
Instructor: Monica
Nicolescu
Lecture 5
Insertion Sort
Idea: like sorting a hand of playing cards
Start with an empty left hand and the cards facing
down on the table
Analysis of Algorithms
CS 477/677
Instructor: Monica
Nicolescu
Lecture
Analysis of Randomized Quicksort
Alg.: RANDOMIZED-QUICKSORT(A,p,r)
if p<r
TherunningtimeofQuicksortisdominated
byPARTITION!
then
Analysis of Algorithms
CS 477/677
Instructor: Monica
Nicolescu
Lecture 11
Interval Trees
Useful for representing a set of intervals
E.g.: time intervals of various events
Each interval ihas a low[i] a
Analysis of Algorithms
CS 477/677
Instructor: Monica
Nicolescu
Lecture 14
Dynamic Programming
Used for optimization problems
Find a solution with the optimal value (minimum or
maximum)
A set of choice
Analysis of Algorithms
CS 477/677
Instructor: Monica
Nicolescu
Lecture 8
General Selection Problem
Select the i-th order statistic (i-th smallest element) form
a set of n distinct numbers
p
k=qp+1
r
A
Analysis of Algorithms
CS 477/677
Instructor: Monica
Nicolescu
Lecture 9
Array Representation of Heaps
A heap can be stored as an
array A.
Right child of A[i]=A[2i+1]
Parent of A[i]=A[i/2]
Left child
Analysis of Algorithms
CS 477/677
Instructor: Monica
Nicolescu
Lecture 10
Red-Black Trees
Balanced binary trees guarantee an O(lgn)
running time on the basic dynamic-set
operations
Red-black tree
Bina
CS 477/677 Analysis of Algorithms
Homework 2
Due September 15, 2015
1. (U & G-required) [30 points] Consider the following algorithm.
ALGORITHM Enigma(A[0.n 1])
/Input: An array A[0.n 1, 0.n 1] of int