Bonus Assignment
CMPT 250 - Summer 2008
Due Date: Thursday, July 31st at 5:30 PM
This assignment is optional. It is intended to provide you with another opportunity to learn how a
processor works at the circuit level and at the same time help you to impro
Assignment I
CMPT 250 - Summer 2008
Due Date: Friday - May 30 at 11:00 PM
Questions
1. In your own words explain the use and functionality of the following programs:
a. Compiler
b. Interpreter
c. Linker
d. Loader
List all book and internet references that
Assignment II
CMPT 250 - Summer 2008
Due Date: Wednesday - July 2nd at 5:00 PM
Questions
1. Using LogicWorks implement a Two Cycle Clock 8-bit RISC processor. The processor has the
following features:
a. All instructions are executed in two cycles:
i. Fet
Longest
Common
Subsquence
By Nathan Nastili
CMPT 307 REVIEW SESSION
JULY 21st 2014
What is a subsequence
FOR EXAMPLE:
S = GGGGTTACTTTAT
Z = G T C A
What is a LCS
FOR EXAMPLE:
X= GTAATTTTAAA
Y= GGGGTTACTTTAT
X= G T A ATTTTAAA
Y= GGGGTTACT
Santa Clause Problem
Getting to know dynamic programming
Lu Gan Computing Science
What is dynamic programming
is a method for solving complex problems
How?
By breaking them down into simpler sub problems
What kind of sub problem?
a) There are only a po
A* Algorithm
BY WARREN RUSSELL
Dijkstras Algorithm
In real time, finding a path can be
time consuming.
Especially with all the
extra cells visited.
Is this practical? Could we do better?
A* (A Star)
This is a shortest path algorithm that avoids exhaustive
Bipartite Matching
Variation of Marriage Problem
Recall marriage problem
Set of men M = cfw_m1, m2, . . . , mn
Set of women W = cfw_w1,w2, . . . ,wn
Want perfect matching M where every man is
married to every woman
Variation of Marriage Problem
Two Ca
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 resource can be used by at most one person at a time.
we c
INTERVAL SCHEDULING
Yu-Ta Cheng
IDEAL
We want to schedule jobs on computer.
Given a set of jobs that can be processes on the
computer.
Many jobs request to process at same time but
our computer can only run one job at a time.
Also we can accept only co
GRAPH SEARCH
BFS & DFS
By: Parminder Benipal
Usage
2
!
!
!
!
Transportation networks (airline carrier, airports as
node and direct flights as edges (direct edge).
Communication networks (a collection of computers as
nodes and the physical link between the
Dynamic Programming
Shortest path with negative edges
BellmanFord algorithm
Shortest Paths: Failed Attempts
Dijkstra Algorithm: shortest path from s to t
Can fail if negative edge costs.
2
u
3
s
v
1
-6
t
Re-weighting. Adding a constant to every edge weigh
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 them recursively or if
they are small, there must be a
Approximation Algorithms (Travelling
Salesman Problem)
July 18, 2014
Approximation Algorithms (Travelling Salesman Problem)
The travelling-salesman problem
Problem: given complete, undirected graph G = (V , E ) with
non-negative integer cost c(u, v ) for
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 problems)
So far we have seen polynomial time problems and w
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 processing time ti 0.
We are given m identical machines.
Approxi
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 guaranteed to be close to
optimal and it can be found in po
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 number of zeros are the same and
in every prex of S the
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 shows a customer in C likes (willing to have) a
subset
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 G contains no negative-weight cycles
Goal: create n n
Shortest path with negative edges
June 16, 2014
Shortest path with negative edges
Shortest path from s to t when there are negative weight arcs, but
no negative cycles
A cycle is negative if sum of the weights of its arcs is less than zero.
Lemma
If G has
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 them recursively or if
they are small, there must be a
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 and G
how to dene similarity?
Dynamic Programming II
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
resource for periods of time (an interval of time)
Each inte
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 resource can be used by at most one person at a time.
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 fastest way to multiply many matrices).
Dynamic Programmin
Graphs and Graphs Traversal
May 12, 2014
Graphs and Graphs Traversal
Graph (Basic Denition)
Graph : Represents a way of encoding pairwise relationships
among a set of objects.
Graph G consists of a collection V of nodes and a collection E of
edges, each o
Shortest Path in Digraphs
May 16, 2014
Shortest Path in Digraphs
Exercises from Wednesday May 14
A digraph T is called tournament if for every two nodes u, v of
exactly one of the uv , vu is an arc in T .
Problem 1: Show that in every tournament there is
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 store binary trees.
nearly complete trees:
all levels
Minimum Spanning Trees
May 23, 2014
Minimum Spanning Trees
Minimum spanning trees (MST)
One of the most famous greedy algorithms
Given undirected graph G = (V , E ), connected
Weight function w : E R
Spanning tree: tree that connects all nodes, hence n =
Graph Search, BFS,DFS,Topological ordering
May 14, 2014
Graph Search, BFS,DFS,Topological ordering
BFS Algorithm
BFS (s)
1. Set Discover[s]=true and Discover[v]=false for all other v
2. Set L[0] = cfw_s
3. Set layer counter i=0
4. Set T =
4. While L[i] i