Divide and Conquer
Counting Inversions
Closest Pair
July 17, 2016
Geoffrey Tien
1
Solving Recurrences
The Master Method
The master method provides a "cookbook" method for solving
recurrences of the f
NP-Completeness
Efficient Certification
NP-Complete Problems
August 04, 2017
Geoffrey Tien
1
Solution Finding vs Solution Checking
Finding solutions to the problems discussed in previous lesson
is di
Asymptotic Notation
Review asymptotic notation
Data structures for Gale-Shapley
Sorting in "linear" time (!)
July 07, 2017
Geoffrey Tien
1
Algorithm Efficiency
What algorithm can we call efficient?
Dynamic Programming
Weighted interval scheduling
Knapsack
July 24, 2017
Geoffrey Tien
1
Algorithmic Paradigms
Greed
Build a solution incrementally, choosing short-term optimization on
some local cri
Network Flow
July 28, 2017
Geoffrey Tien
1
Flow Networks
Think of a graph as a fluid system
edges are pipes carrying liquid
nodes are junctures where pipes are plugged together
We use this system
Flow Networks
Max-flow min-cut (take 2!)
Matchings
Extensions
July 31, 2017
Geoffrey Tien
1
Max Flow vs Min Cut
Let be the flow returned by the Ford-Fulkerson algorithm
we find a cut (, ) such that
NP-Completeness
August 02, 2017
Geoffrey Tien
1
Efficiency
Review
So far, we have considered problems that can be solved
efficiently
i.e. in polynomial time
P = cfw_problems solvable in polynomial
Greedy Algorithms
Huffman codes
Shortest paths
Spanning trees
July 12, 2017
Geoffrey Tien
1
Binary Encodings
Data Compression
All data in a computer system are represented as binary
sequences, i.e. s
Divide and Conquer
Integer Multiplication
Quicksort (quick) Analysis
July 19, 2017
Geoffrey Tien
1
Integer Multiplication
Back to grade school!
Multiplication of two -digit numbers
Produce partial p
Amortized Analysis
Union-Find data structure
(Kruskal's Algorithm implementation)
Recurrence relations
July 14, 2017
Geoffrey Tien
1
Amortized Analysis
Suppose we are dealing with an algorithm or dat
Computer Cycling, Low Level Programming
The exercise numbers below refer to the exercises in Lab #7 of the lab manual, see LabCH07.pdf.
Useful Links
Lab manual applets: : http:/faculty.mc3.edu/pvetere
CPSC 320 2016W1: Assignment 2 Sample Solution
October 6, 2016
This is a
SAMPLE SOLUTION. Your responses may dier from ours and still be correct.
Review
this solution and think about how it compares to
CPSC 320 2016W1: Assignment 4 Sample Solution
November 9, 2016
1
The Price Isn't Always Right
Aconcagua.com sells storage on both an auction and xed-price basis. They want to use historical auction
da
CPSC 320 2016W1: Assignment 2
September 25, 2016
Submit this assignment via handin (see the syllabus for more information) to the target
assn2
by
Thursday 6 Oct at 10PM (note the change in time, thank
CPSC 320 2016W1: Assignment 4
2016-10-20 Thu
Submit this assignment via handin (see the syllabus for more information) to the target
assn4
by the
deadline Thursday 10 Nov at 10PM. For credit, your gro
Hanlin Liu x2m0b
All group members have read and followed the guidelines for academic conduct in
CPSC 320. As part of those rules, when collaborating with anyone outside my group,
(1) I and my collabo
student1: Jeongeun Kim, p7p0b
student2: Hanlin Liu, x2m0b
All group members have read and followed the guidelines for academic conduct in CPSC
320.
As part of those rules, when collaborating with anyo
CPSC 320 2016W1: Assignment 1 Sample Solution
September 22, 2016
This is a
SAMPLE SOLUTION. Your responses may dier from ours and still be correct.
Review
this solution and think about how it compares
CPSC 320 2016W1: Assignment 1
September 12, 2016
Submit this assignment via handin (see the syllabus for more information) to the target
deadline
assn1
by the
Thursday 22 Sep at 5PM. For credit, your
1.1
1. INSERT(M,3), INSERT(M,2), INSERT(M,1), FINDMEDIAN(M)
2. Insert 3, 2 and 1 in order. After implement the Insert procedure, 1 will be
stored in the MedianDS.Left while 2 and 3 are stored in Media
CPSC 320 Sample Solution: The Futility of Laying Pipe, Part 2
November 23, 2016
We've already shown that SP
NP. To show it's NP-complete, we need to also show that it is NP-hard;
that is, that it's a
CPSC 320 Sample Solution: The Futility of Laying Pipe, Part 1
November 18, 2016
UBC recently replaced its aging steam heating system with a new hot water system. A set of locations
needs water deliver
CPSC 320 Sample Solution, PageRank and Clustering
October 3, 2016
1
PageRank
SOLUTION: We don't supply any specic solutions to this problem. The goal here was to frame a famous
problem in graphs yours
CPSC 320 Sample Solution, Asymptotic Analysis
September 21, 2016
1
Comparing Orders of Growth for Functions
For each of the functions below, give the best
bound you can nd and then arrange these funct
CPSC 320 Sample Soln: Memoization and Dynamic Programming,
Part 1
October 27, 2016
You work for the First CitiWide Bank, a bank that makes change. That's just what you do.
1
Greedy Change
Assuming an
CPSC 320 Sample Solution, The Stable Marriage Problem
September 10, 2016
This is a sample solution that illustrates how we might solve parts of this worksheet. Your answers
may vary greatly from ours
CPSC 320 Sample Solution, Reductions and Resident Matching: A
Residentectomy
September 16, 2016
A group of residents each needs a residency in some hospital.
A group of hospitals each need some
number
CPSC 320 Sample Soln: Memoization and Dynamic Programming,
Part 2
November 10, 2016
1
If I Had a Nickel for Every Time I Computed That
1. Rewrite
CCC,
this time storingwhich we call memoizing, as in t
CPSC 320 Notes: What's in a Reduction? Solution-ish stu
November 14, 2016
1 Boolean Satisability
1. Here's the example in our specied format:
5
4
1
1
3
2
/ 5 clauses
/ a clause with 4 literals: x1, no