COMP3609 Algorithms and Complexity (Advanced)
Edmund Tse 2008
Chapter 5 Divide and Conquer
Divide and conquer
o Break up problem into several parts
o Solve each part recursively
o Combine solutions to sub-problems into overall solution
Most common usage
o
COMP3609 Algorithms and Complexity (Advanced)
Edmund Tse 2008
o
Cycle property. Let C be any cycle, and let f be the max cost edge belonging to C. Then the MST does
not contain f.
o
Cycle. Set of edges that form a-b, b-c, c-d, , y-z, z-a
o
Cutset. A cut i
COMP3609 Algorithms and Complexity (Advanced)
Edmund Tse 2008
Chapter 2 Basics of Algorithm Analysis
Computational Tractability
Polynomial time
o Natural brute-force search algorithm, checking every possible solution
o Usually 2N time or worse
o Desirable
Due: 27th of May 2016 at 11pm
Submit your assignment via Blackboard (turnitin). Submission must be in pdf
format, and cannot be handwritten.
COMP 9007 Assignment 4
As a first step go to the last page and read the section: Advice on how to do
the home work
Due: 24th of April 2016 at 11pm
Submit your assignment via Blackboard (turnitin). Submission must be in pdf
format, and cannot be handwritten.
COMP 9007 Assignment 2
As a first step go to the last page and read the section: Advice on how to do
the home wo
Due: 31th of March 2016 at 11pm
COMP 9007 Assignment 1
As a first step go to the last page and read the section: Advice on how to do
the home work.
1. Sort the following functions by order of growth from slowest to fastest
(big-O notation). For each pair
Due: 12th of May 2016 at 11pm
Submit your assignment via Blackboard (turnitin). Submission must be in pdf
format, and cannot be handwritten.
COMP 9007 Assignment 3
As a first step go to the last page and read the section: Advice on how to do
the home work
Basic data structures
1
Why data structures?
Programs manipulate data
Data should be organized so manipulations will be efficient
- Search (e.g. Finding a word/file/web page)
Better programs are powered by good data structures
Nave choices are often m
Basic data structures
1
Why data structures?
Programs manipulate data
Data should be organized so manipulations will be efficient
- Search (e.g. Finding a word/file/web page)
Better programs are powered by good data structures
Nave choices are often m
Five Representative Problems: Interval Scheduling
Input. Set of jobs with start times and finish times.
Goal. Find maximum cardinality subset of mutually compatible jobs.
jobs don't overlap
a
b
c
d
e
f
g
h
0
1
2
3
4
5
6
7
8
9
Time
10
11
1
Weighted Inter
Basic data structures
1
Why data structures?
Programs manipulate data
Data should be organized so manipulations will be efficient
- Search (e.g. Finding a word/file/web page)
Better programs are powered by good data structures
Nave choices are often m
Minimum Spanning Tree
The University of Sydney
Page 1
Minimum Spanning Tree
Minimum spanning tree (MST). Given a connected graph G = (V,
E) with real-valued edge weights ce, an MST is a subset of the edges
T E such that T is a spanning tree whose sum of
COMP3609 Algorithms and Complexity (Advanced)
Edmund Tse 2008
Correctness follows immediately from previous lemma.
Directed acyclic graphs
Def. A DAG is a directed graph that contains no directed cycles
Ex. Precedence constraints: edge (vi, vj) means node
COMP3609 Algorithms and Complexity (Advanced)
Edmund Tse 2008
o
Case 2: otherwise, insert e = (u, v) into T according to cut property where S = set of nodes in us
connected component.
Implementation. Use the union-find data structure.
Build set T of edge
COMP3609 Algorithms and Complexity (Advanced)
Edmund Tse 2008
General
Lecturer
o Taso Viglas
o SIT 413
o tasos@it.usyd.edu.au
Assessment
o 20%
Assignments
o 20%
Midterm quiz
o 60%
Final exam
Reference Book
o Kleinberg and Tardos Algorithm Design
Chapter 1
COMP3609 Algorithms and Complexity (Advanced)
Divide and conquer
o
o
o
Edmund Tse 2008
Divide: separate list into two pieces
Conquer: recursively count inversions in each half
Combine: count inversions where ai and aj are in different halves, and return s
COMP3609 Algorithms and Complexity (Advanced)
Edmund Tse 2008
Chapter 4 Greedy Algorithms
Interval scheduling
Interval scheduling
o Job starts at sj and finishes at fj.
o Two jobs are compatible if they dont overlap
o Goal: find the maximum subset of mutu
COMP3609 Algorithms and Complexity (Advanced)
Edmund Tse 2008
o
Consider lectures in increasing order of start time, assigning lecture to any compatible classroom
o
Implementation. O(n log n)
For each classroom k, maintain the finish time of the last job
COMP9007 - Algorithms
Greedy algorithms
The University of Sydney
Page 1
Greedy algorithms
A greedy algorithm is an algorithm that follows the
problem solving heuristic of making the locally optimal
choice at each stage with the hope of finding a global
op