CMPT 307
Solutions to Midterm #1
October 14, 2008
NO AIDS ALLOWED. Answer ALL questions on test paper. Use backs of sheets for scratch work. Total Marks: 55 ADVICE: Do this page fast! [5] 1. True or F
CMPT-454 Fall 2009 Instructor: Martin Ester TA: Yi Liu Solution Assignment 1
Total marks: Due date:
200 (20 % of the assignments) September 30, 2009
Problem 1.1 (50 marks) Consider a disk with a secto
Divide and Conquer
June 2, 2014
Divide and Conquer
Divide the problem into a number of subproblems
Divide and Conquer
Divide the problem into a number of subproblems
Conquer the subproblems by solving
Dynamic Programming II
June 9, 2014
Dynamic Programming II
DP: Longest common subsequence
biologists often need to nd out how similar are 2 DNA
sequences
DNA sequences are strings of bases: A, C , T
Dynamic Programming( Weighted Interval
Scheduling)
June 11, 2014
Dynamic Programming( Weighted Interval Scheduling)
Problem Statement:
1
2
3
We have a resource and many people request to use the
resou
Divide and Conquer
June 4, 2014
Divide and Conquer
Divide the problem into a number of subproblems
Divide and Conquer
Divide the problem into a number of subproblems
Conquer the subproblems by solving
Exercises
June 23, 2014
Exercises
Going from A to B using one unit diagonal moves
A
,
.
B
From A to B using
A
B
Exercises
Denition : We say a sequence S of 0, 1 is nice if the number of
ones and the n
Dynamic Programming( All pairs shortest
path)
June 25, 2014
Dynamic Programming( All pairs shortest path)
All-pairs shortest paths
Directed graph G = (V , E ), weight function
w : E R, |V | = n
Assume
Approximation Algorithms (vertex cover)
July 14, 2014
Approximation Algorithms (vertex cover)
Consider a problem that we can not solved in polynomial time.
We may be able to nd a solution that is guar
Matching in Bipartite Graphs
July 2, 2014
Matching in Bipartite Graphs
We have a bipartite graph G = (C , R, E ) where R represents a set
of resources and C represents a set of customers.
The edge set
Hard Problems (NP problems)
July 9, 2014
Hard Problems (NP problems)
So far we have seen polynomial time problems and we have
designed (attempt) ecient algorithm to solve them.
Hard Problems (NP probl
Approximation Algorithms (Travelling
Salesman Problem)
July 18, 2014
Approximation Algorithms (Travelling Salesman Problem)
The travelling-salesman problem
Problem: given complete, undirected graph G
Approximation Algorithms (Load Balancing)
July 16, 2014
Approximation Algorithms (Load Balancing)
Problem Denition :
We are given a set of n jobs cfw_J1 , J2 , . . . , Jn .
Each job Ji has a processin
Exercises
June 18, 2014
Exercises
Scheduling Jobs with Deadlines and Prots
Problem Statement: We have a resource and many people
request to use the resource for one unit of time.
Conditions:
the reso
CMPT 307, Assignment 1
Deadline: Friday, June 13 (5:00 pm)
Problem 0.1 Rank the following functions by the order of growth :
4
n
2log n , 2n , n 3 , n log n, nlog n , 22 , 2
n
You need to arrange them
CMPT 307, Assignment 2
Deadline Monday June 30th (5:00 pm)
Problem 0.1 Write a pseudo code for nding a longest weighted path between two given
nodes u, v in an acyclic digraph D.
Problem 0.2 Modify th
CMPT 307, Assignment 3
Deadline Monday July 21 (5:00 pm)
Problem 0.1 Show the steps of all pairs shortest path algorithm on this example.
2
3
4
1
8
-4
2
3
1
-5
7
5
6
4
Problem 0.2 We are given a weigh
Dynamic Programming
June 6, 2014
Dynamic Programming
Dynamic Programming
1
Dynamic programming algorithms are used for optimization
(for example, nding the shortest path between two points, or
the fas
Heap, HeapSort and Priority Queue
May 28, 2014
Heap, HeapSort and Priority Queue
Heap
A heap (data structure) is a linear array that stores a nearly
complete tree.
Only talking about binary heaps that
Interval Scheduling
May 30, 2014
Interval Scheduling
Interval Scheduling Problem
Problem Statement: We have a resource and many people
request to use the resource for periods of time.
Conditions:
the
CMPT-454 Fall 2009 Instructor: Martin Ester TA: Yi Liu Solution Assignment 2
Total marks: Due date:
200 (20 % of the assignments) October 14, 2009
Problem 2.1 (50 marks) Consider B-trees of order n =
CMPT-454 Spring 2009 Instructor: Martin Ester TA: Bahareh Bina Sample Exam
Problem 1 Given two relations R(a,b,c) and S(a,b,d) with the following statistics: T(R) = 1000, V(R,a) = 1000, V(R,b) = 50, V
CMPT-454 Spring 2009 Instructor: Martin Ester TA: Bahareh Bina Solution Assignment 10 Total marks: Due date: 100 (10 % of the assignments) April 6, 2009
Problem 10.1 (40 marks) Consider the following
CMPT 307 - Data Structures and Algorithms: Solutions to PS 1
September 25, 2008
1. Asymptotics Rank the following functions by order of growth; that is, arrange the following 14 functions g1 , . . . ,
CMPT 307 - Data Structures and Algorithms: Solutions to Problem Set 2
October 9, 2008
1. Topological ordering. Let G = (V, E ) be a directed acyclic graph (DAG). A topological ordering of G is a seque
CMPT 307 - Data Structures and Algorithms: Solutions to Problem Set 3
November 5, 2008
1. Making change Youre given an unlimited supply of coins of denominations d1 , d2 , . . . , dk (where each di is
CMPT 307 - Data Structures and Algorithms: Solutions to Problem Set 4
1. Forming committees In a certain department, there are n faculty members. The department needs to organize m dierent committees
CMPT 307
Solutions to Midterm #2
November 13, 2008
[3] 1. True or False? (Below, Pr[X ] stands for the probability of an event X .) (a) For any random events A and B , Pr[A & B ] = Pr[A] Pr[B | A]. (b
CMPT-454 Fall 2009 Instructor: Martin Ester TA: Yi Liu Solution Assignment 3
Total marks: Due date:
200 (20 % of the assignments) October 28, 2009
Problem 3.1 (30 marks) Consider the following simplif
Course Information and Introduction
Arash Raey
May 5, 2014
Arash Raey
Course Information and Introduction
Course Information CMPT 307
1
Instructor : Arash Raey
Email : [email protected]
Oce : TACS1 9215
O