4. G REEDY A LGORITHMS II
Dijkstra's algorithm
minimum spanning trees
Prim, Kruskal, Boruvka
single-link clustering
min-cost arborescences
SECTION 6.1
Cycles and cuts
Def. A path is a sequence of edges which connects a sequence of nodes.
Def. A cycle
CPSC 320 2017/01/05 Pre-Class Quiz
Regarding Section 1.1 of the textbook.
Page 1
Mark each of these statements that is true of the Gale-Shapley algorithm (with men proposing):
Missing the challenging one alone won't bring you down from a 2/2!
Independent
CPSC 320 2017/01/19 Pre-Class Quiz
Regarding Chapter 3, Sections 1-3 of the textbook.
Page 1
For the first three questions (asking "Is this list of vertices.?"), consider this list of vertices: v1, v3, v2, v7, v1 from a
graph containing 10 vertices v1, v2
CPSC 320 Midterm #1 Sample Solution
February 4, 2015
1
A Capital Idea [11 marks]
1. In each row below, circle the correct statement if we know that for all positive integers
n, f (n) < g(n).
[8 marks]
SOLUTION: We can easily prove f (n) O(g(n) by setting
CPSC 320 2017/01/15 Pre-Class Quiz
Regarding Chapter 2 of the textbook (which should mostly be review).
Page 1
We sometimes define "efficient" in algorithms as "polynomial time". Which of these is in "polynomial time"?
linear
lg n (equivalent aspmytotical
CPSC 320 Sample Solution: DP in 2-D
March 4, 2017
A and B is the longest string whose letters appear in
A and B. For example, the LCS of eleanor and naomi
2 string ao).
The Longest Common Subsequence of two strings
order (but not necessarily consecutively
Gale-Shapley algorithm (based on treatment in Kleinberg and Tardoss Algorithm Design):
S TABLE -M ARRIAGE(, )
1 initialize all men in and women in to unengaged
2 while an unengaged man with at least one woman on his preference list remains
3
do choose suc
CPSC 320 Notes, PageRank
January 24, 2017
Imagine the following graph represents the follows structure of CS department faculty on Twitter:
Discuss these questions with your neighbour:
Who's the biggest bigwig (important person) in the group?
Who's the se
CPSC 320 Little-o/Little- Overview
September 19, 2016
Big
O, ,
and
are
roughly equivalent to asymptotic , =,
< and > to dene.
and
comparisons on functions. That
naturally leaves analogues of
1 Formal Denitions via Logic
f (n) is little-o of another functi
CPSC 320o 2014W2 Final Exam Practice Problems
April 15, 2015
Px
Px
Px
y=1 y
y=1 y
=
2
y
y=0 2
x(x+1)
, for
2
=
x 0.
x(x+1)(2x+1)
, for
6
= 2x+1 1,
For a recurrence like
for
x 0.
x 0.
T (n) = aT ( nb ) + f (n),
where
a1
and
b > 1,
the Master Theorem states
CPSC 320 Midterm #1
February 4, 2015
1
2
but do not miss the problem also on this page!):
Reminders (
f (n) O(g(n) (big-O, that is) exactly when there is
n0 such that for all integers n n0 , f (n) c g(n).
a positive real constant
f (n) o(g(n) (little-o,
CPSC 320: Intermediate Algorithm Design and Analysis
Assignment #1, due Monday July 7th, 2014 at 18:00
[8] 1. As stated in class and proved in the textbook, the stable matching algorithm of Gale and
Shapley gives the best possible results for the side tha
CPSC 320: Intermediate Algorithm Design and Analysis
Assignment #1, due Monday July 7th, 2014 at 18:00
[8] 1. As stated in class and proved in the textbook, the stable matching algorithm of Gale and
Shapley gives the best possible results for the side tha
CPSC 320 Another Sample Midterm 1
October 2014
[12] 1. Short Answers
[3] a. Why is it useful to know that the furthest-in-the-future cache maintenance algorithm
is optimal, even though it can not be implemented in practice?
Solution : It is because we can
CPSC 320: Intermediate Algorithm Design and Analysis
Assignment #5, due Friday, August 1th , 2014 at 18:00
[12] 1. Given a set of n numbers, we wish to find the i largest in sorted order using a comparisonbased algorithm. We consider these three strategie
CPSC 320: Intermediate Algorithm Design and Analysis
Assignment #2, due Friday, July 11st , 2014 at 18:00
[6] 1. King Yemechan was angry because the solutions proposed to help him determine
which wine bottle was poisoned all used too many taste testers. D
CPSC 320: Intermediate Algorithm Design and Analysis
Assignment #6, due Friday, August 8th , 2014 at 18:00
[30] 1. Tim and Jim are twin brothers who just had their joint birthday party. Among the presents
that they received, they got n gift cards. They wa
CPSC 320 2017/01/08 Pre-Class Quiz
Covering the worked example for this lecture. (See the handouts/notes on the course website!)
Page 1
In the worked example, did we conclude that USMP has more, fewer, or the same number of trivial instances as SMP?
More
a Bag of Make Me Words
January 7, 2017
A standard part of text analysisfor machine learning, machine translation, sentiment analysis, and so
onis transforming a document into a bag of words representation. A bag of words is a data structure
that maps the
How to Solve a 320 Problem
September 7, 2016
1.
Trivial and small instances:
(a) Write down at least one trivial problem instance (and enough to cover all the problem's trivial
cases).
(b) Write down at least one small but non-trivial problem instance (an
CPSC 320 2016W2: Quiz 1 Pre-Release Information
January 8, 2017
This week's quizzes will follow up on the problem domains described below. It's worth spending a few
minutes reading and understanding each domain before your tutorial!
Note that if you colla
CPSC 320 Sample Solution, The Stable Marriage Problem
January 4, 2017
1
Trivial and Small Instances
1. Write down all the
trivial instances of SMP. We think of an instance as trivial roughly if its solution
requires no real reasoning about the problem.
SO
CPSC 320 Notes, The Stable Marriage Problem
January 3, 2017
The major goal of CPSC 320 is, of course, romantic advice. That's a heavy topic over which to meet
your classmates. So, we use candy and baked goods to stand in for love (a surprisingly common pr
CPSC 320 2016W2, Sample Solution: Assignment #2
February 4, 2017
1
Cluedo Something to Me
The new game Clue II (CII, for short) is about a group of
n people, each intent on stealing one of n objects.
Each person moves about a mansion picking up and puttin
CPSC 320 Sample Soln: Memoization and Dynamic Programming,
Part 2
March 1, 2017
1
If I Had a Nickel for Every Time I Computed That
1. Rewrite
CCC,
this time storingwhich we call memoizing, as in take a memo about thateach
solution as you compute it so tha
CPSC 320 Sample Solution: Physics, Tug-o-War, and
Divide-and-Conquer
February 4, 2017
In tug-o-war, two teams face each other and
carefully pull on a well-selected rope (to avoid injury).
The team that pulls the other past the centerline wins. The heavier
CPSC 320 Sample Solution, Clustering
February 4, 2017
You're working on software to manage people's photos. Your algorithm receives as input:
a bunch of uncategorized photos,
the number of categories to group them into (i.e., how many categories to use),
CPSC 320 2016W2: Assignment #2
January 23, 2017
Please submit this assignment via GradeScope at https:/gradescope.com. Detailed instructions about
how to do that are pinned to the top of our Piazza board: https:/piazza.com/ubc.ca/winterterm22016/cpsc320/.
Introduction to Algorithms
Massachusetts Institute of Technology
Professors Erik Demaine and Sha Goldwasser
March 18, 2004
6.046J/18.410J
Handout 14
Lecture Notes on Skip Lists
Lecture 12 March 18, 2004
Erik Demaine
Balanced tree structures we know at thi
CPSC 320 2016W2: Quiz 3 Sample Solution
February 9, 2017
1
Greedy banks resequencing debits
Predatory banks take the debits to an account that occur over the day and reorder them to maximize
the fees they can charge. For each debit that results in taking