Introduction to Analysis of Algorithms and Data Structures
PHYSICS 2331

Fall 2013
CIS 2331 Homework 10
Note: These questions are just for your exercises. You dont need to submit your
solutions for grading.
Final exam: closedbook, opennotes
Date/Time: Wednesday Dec 12, 4:00pm5:45
Introduction to Analysis of Algorithms and Data Structures
PHYSICS 2331

Fall 2013
CIS 2331 Homework 9
Due: Friday, November 16 by class time
Note: use the definition of flow that includes the skewsymmetry condition.
1. The following figure shows a flow in a network. Construct the
Introduction to Analysis of Algorithms and Data Structures
PHYSICS 2331

Fall 2013
CSE 2331 Homework 8
Due Friday, November 9 by class time
Autumn, 2012
1. Give the EDGES of the minimum spanning tree of the weighted graph in Figure 1 in the order they
would be output by Prims algori
Introduction to Analysis of Algorithms and Data Structures
PHYSICS 2331

Fall 2013
CSE 2331 Homework 7
Autumn, 2012
Due: Friday, November 3 by class time
1. Consider the following undirected graph:
?>=<
89:;
?>=<x
89:;
2b
1F x
FF xxxxx bbb
FF xxxx bb
xxxbbb
FF
xx
F
?>=<
89:;
?>=<
Introduction to Analysis of Algorithms and Data Structures
PHYSICS 2331

Fall 2013
CSE2331 Homework 6
Due Wednesday, October 24, by class time
1. Let G = (V, E ) be an undirected graph. Modify the following algorithm
to determine if G is a tree. (A tree is a connected graph without
Introduction to Analysis of Algorithms and Data Structures
PHYSICS 2331

Fall 2013
CSE 2331 Homework 5
Autumn, 2012
(Just for your practice; you dont need to submit anything)
Midterm II: Monday, October 8
Scope: Slides 51129, and notes on Divide and Conquer, Heapsort and Priority Q
Introduction to Analysis of Algorithms and Data Structures
PHYSICS 2331

Fall 2013
CSE 2331 Homework 4 (part II)
Due: Wednesday, October 3rd by class time
Midterm Exam II: Monday, October 8.
Scopes: materials after the quiz to part of redblack trees.
1. (a) Draw the binary tree pro
Introduction to Analysis of Algorithms and Data Structures
PHYSICS 2331

Fall 2013
CSE2331 Homework 4
Due: Friday, September 28 by class time
(A headsup: HW5 will be due on Wednesday, October 3)
Midterm: Monday, October 8.
1. In the CovexHull algorithm, we assumed that no two poin
Introduction to Analysis of Algorithms and Data Structures
PHYSICS 2331

Fall 2013
CSE 2331 Homework 3
Due: Friday, September 21 by class time
Note: there are 10 problems. Write a recurrence relation describing the worst case
running time of each of the following algorithms and dete
Introduction to Analysis of Algorithms and Data Structures
PHYSICS 2331

Fall 2013
CSE 2331 Homework 2
Autumn, 2012
Due: Friday, September 7, by class time
Note: there are six questions.
1. Give the asymptotic running time of the following function in notation.
Justify your answer.
Introduction to Analysis of Algorithms and Data Structures
PHYSICS 2331

Fall 2013
CSE2331 Homework 1
Autumn, 2012
Due: Wednesday, September 5, by class time
Give upper and lower bounds on the running time of each of the following
algorithms. Your upper and lower bounds should dier
Introduction to Analysis of Algorithms and Data Structures
PHYSICS 2331

Fall 2013
Dynamic Programming
Reading: CLRS Chapter 15 & Section 25.2
CSE 2331 Algorithms
Steve Lai
Optimization Problems
Problems that can be solved by dynamic programming
are typically optimization problems.
Introduction to Analysis of Algorithms and Data Structures
PHYSICS 2331

Fall 2013
Sorting in Linear Time
CSE 2331
Suggested Reading: Sections 8.1, 8.2, 8.3
1
Lower Bounds for Sorting
Insertionsort, mergesort, heapsort, quicksort are all based on comparison. We sort by comparing e
Introduction to Analysis of Algorithms and Data Structures
PHYSICS 2331

Fall 2013
Maximum Flow
Reading: CLRS Sections 26.126.3
(skipping Lemma 26.8, Theorem 26.9 (2nd edtion)
or Lemma 26.7, Theorem 26.8 (3rd edition)
CSE 2331
Steve Lai
Flow Network
A flow network G = (V , E ) is
Introduction to Analysis of Algorithms and Data Structures
PHYSICS 2331

Fall 2013
Minimum Spanning Trees
CSE 2331
Suggested Reading: Chapter 23.
1
Greedy Method
Optimization Problem:
Construct a sequence or a set of elements cfw_x1 , . . . , xk that satises some
given constraints
Introduction to Analysis of Algorithms and Data Structures
PHYSICS 2331

Fall 2013
Heapsort and Priority Queues
CSE 680
Suggested reading: Chapter 6
1
Heaps
Complete binary tree: a binary tree with exactly 2h leaves, where
h is the height of the tree.
Nearly complete binary tree:
Introduction to Analysis of Algorithms and Data Structures
PHYSICS 2331

Fall 2013
DivideandConquer
CSE 680
1
Introduction
Given an instance x of a problem, the divideandconquer method works as follows.
function DAQ(x)
if x is sufciently small or simple then
solve it directly
el
Introduction to Analysis of Algorithms and Data Structures
PHYSICS 2331

Fall 2013
What is this functions time
complexity?
Sample for loops
Sample for loops
Sample for loops
Sample for loops
Sample for loops
Sample while loops
Sample while loops
Sample while loops
Sample while loops
Introduction to Analysis of Algorithms and Data Structures
PHYSICS 2331

Fall 2013
Examples
For each of the following functions fi (n), express its asymptotic
complexity in a simplest form such as (1), (log2 n), (log2 log2 n),
(n), (n log n), (nk ), (2n ), etc.
1. f (n) = 45n+9 = (
Introduction to Analysis of Algorithms and Data Structures
PHYSICS 2331

Fall 2013
Mathematical Foundation
CSE 680
Suggested Reading: Sections 1.1, 1.2, 2.1, 2.2, 3.1, 3.2.
1
Running Time
Analysis of algorithm: to estimate the running time of an algorithm.
Elementary operations:
Introduction to Analysis of Algorithms and Data Structures
PHYSICS 2331

Fall 2013
RedBlack Trees
Source: wikipedia.org
RedBlack Tree Properties
(Definition of RB Trees)
A redblack tree is a BST with following properties:
1. Every node is either red or black.
2. The root is black