Chapter 15: Dynamic
Programming III
Subsequence of a String
Let S = s1s2sm be a string of length m
Any string of the form
si1 si2 sik
with i1 i2 ik is a subsequence of S
E.g., if S = farmers
fame, arm, mrs, farmers, are some
of
the subsequences of S
2
Chapter 15: Dynamic
Programming II
Matrix Multiplication
Let A be a matrix of dimension p x q
and B be a matrix of dimension q x r
Then, if we multiply matrices A and B,
we obtain a resulting matrix C = AB
whose dimension is p x r
We can obtain each en
Chapter 6 Heapsort
1
About this lecture
Introduce Heap
Shape Property and Heap Property
Heap Operations
Heapsort: Use Heap to Sort
Fixing heap property for all nodes
Use Array to represent Heap
Introduce Priority Queue
2
Heap
A heap (or binary heap) is
The Role of Algorithms in
Computing
What will we study?
Look at some classical algorithms on different
kinds of problems
How to design an algorithm
How to show that an algorithm works correctly
How to analyze the performance of an
algorithm
1.1 Algori
Chapter82:SortinginLinear
Time
About this lecture
Sortingalgorithmswestudiedsofar
Insertion,Selection,Merge,Quicksort
determinesortedorderbycomparison
Wewilllookat3newsortingalgorithms
CountingSort,RadixSort,BucketSort
assumesomepropertiesontheinput
Chapter 15-1 : Dynamic
Programming I
About this lecture
Divide-and-conquer strategy allows us to
solve a big problem by handling only
smaller sub-problems
Some problems may be solved using a
stronger strategy: dynamic programming
We will see some examp
Chapter 4 Divide-and-Conquer
1
About this lecture (1)
Recall the divide-and-conquer paradigm, which
we used for merge sort:
Divide the problem into a number of subproblems
that are smaller instances of the same problem.
Conquer the subproblems by solvi
University of Waterloo Department of Electrical and Computer Engineering SE 240 Algorithms and Data Structures Spring 2009
Midterm Examination
Instructor: Ladan Tahvildari, PhD, PEng Date: Tuesday, June 23, 2009, 5:30 p.m. Location: DWE 3518 Duration: 2 h
University of Waterloo Department of Electrical and Computer Engineering SE 240 Algorithms and Data Structures Spring 2007
Midterm Examination
Instructor: Ladan Tahvildari Date: Monday, June 11, 2007, 6:30 p.m. Duration: 1.5 hours Type: Closed Book
Instru
University of Waterloo Department of Electrical and Computer Engineering SE 240 Algorithms and Data Structures Spring 2006
Midterm Examination
Instructor: Ladan Tahvildari Date: Monday, June 12, 2006, 4:30 p.m. Duration: 1.5 hours Type: Closed Book
Instru
University of Waterloo Department of Electrical and Computer Engineering SE 240 Algorithms and Data Structures Spring 2005
Midterm Examination
Instructor: Ladan Tahvildari Date: Monday, June 13, 2005, 4:30 p.m. Duration: 2 hours Type: Closed Book
Instruct
University of Waterloo Department of Electrical and Computer Engineering SE 240 Algorithms and Data Structures Spring 2004
Midterm Examination
Instructor: Ladan Tahvildari Date: Monday, June 21, 2004, 7:00 p.m. Duration: 2 hours Type: Closed Book
Instruct
University of Waterloo Department of Electrical and Computer Engineering SE 240 Algorithms and Data Structures Spring 2006
Final Examination
Instructor: Ladan Tahvildari Date: Tuesday, August 1, 2006 Time: 4:00 p.m. to 6:30 p.m. Duration: 2.5 hours Type:
University of Waterloo Department of Electrical and Computer Engineering SE 240 Algorithms and Data Structures Spring 2005
Final Examination
Instructor: Ladan Tahvildari Date: August 4, 2005 Time: 4:00 p.m. to 6:30 p.m. Duration: 2.5 hours Type: Closed Bo
University of Waterloo Department of Electrical and Computer Engineering SE 240 Algorithms and Data Structures Spring 2004
Final Examination
Instructor: Ladan Tahvildari Date: Monday, August 9, 2004, 9:00 a.m. to 12:00 noon. Duration: 3 hours Type: Specia
CS 170 Fall 2009
1. (10 pts.) RSA Problem 1.42 Solution
Algorithms Christos Papadimitriou
HW 2 Solutions
We know that p is a prime and gcd(e, p - 1) = 1. Using the extended Euclidean algorithm find integers x, y such that xe + y(p - 1) = 1. We then have t
CS 170 Fall 2009
Algorithms Christos Papadimitriou
HW 1
Due September 4th, 7pm
Instructions: Please write your name, your TAs name, your discussion section time (e.g., Fri 11am) prominently on the rst page of your homework. Also list your study partners f
15-451
Rec. 2
1
15-451: Algorithms
Recitation 4: Amortized Analysis
1
Bits and Trits
Suppose we have a binary counter such that the cost to increment the counter is equal to the number of bits that need to be ipped. We saw in class that if the counter beg
Recitation 2 : Helping out with homework 1
15-451 : Algorithms
1 Asymptotics of polynomials - RLC page 33
Given a positive integer , a polynomial in n of degree is a function ( ) of the form: d i ( )= i
d pn pn
X
i=0
d
a :n
where d 6= 0. ( ) is asymptotic
22C : 231 Design and Analysis of Algorithms Midterm Exam
The duration of this exam is one hour and fteen minutes. This is a closed-book exam. 1. (10 points) (a) We are given a ow network G with vertex set V and a nonnegative integer capacity c(u, v ) for
22C : 031 Algorithms Midterm
This is a closed book exam. You have an hour and fteen minutes. 1. Give an asymptotically tight bound on the worst case running time of the following algorithm as a function of n, the number of elements in input array A and ou
CS 373g: Algorithms, Fall 2003
Midterm October 2, 2003
Name: Net ID: Alias:
This is a closed-book, closed-notes, open-brain exam. If you brought anything with you besides writing instruments and your handwritten 8 1 11 cheat sheet, please leave it at 2
t
Algorithms CS 25, Fall 2009
Midterm Exam Due: Wednesday, November 4, before start of class
General Instructions
1. Please type your answers or write clearly. There are ve problems on the exam, please start each problem on a dierent sheet of paper. 2. Expr
University of Toronto Scarborough Campus October 16, 2009 CSC C73 Midterm Examination Instructor: Vassos Hadzilacos
Aids allowed: One 8.5 11 cheat sheet (may be written on both sides) Duration: One hour and fty minutes
There should be 7 pages in this ex
Algorithms CMSC-37000 Final Exam. March 14, 2006
Instructor: Lszl Babai ao Show all your work. Do not use text, notes, or scrap paper. When describing an algorithm in pseudocode, explain the meaning of your variables (in English). This exam contributes 30
Introduction to Algorithms Massachusetts Institute of Technology Professors Erik Demaine and Shafi Goldwasser
November 18, 2002 6.046J/18.410J Quiz 2
Quiz 2
Do not open this quiz booklet until you are directed to do so. Read all the instructions first.
Introduction to Algorithms Massachusetts Institute of Technology Professors Erik Demaine and Shafi Goldwasser
October 7, 2002 6.046J/18.410J Quiz 1
Quiz 1
Do not open this quiz booklet until you are directed to do so. Read all the instructions first. Fo
Introduction to Algorithms Massachusetts Institute of Technology Singapore-MIT Alliance Professors Erik Demaine, Lee Wee Sun, and Charles E. Leiserson
October 17, 2001 6.046J/18.410J SMA5503 Quiz 1 Solution
Quiz 1 Solution
Figure 1: grade distribution
Pro