CS/SE 2C03 - Assignment 3 Solution
Adam Lenarcic
1. Exercise 22.1-4
Make a new empty adjacency-list (size V ).
Repeat for each vertex vi cfw_1 i |V |:
For each vertex vj in vi s list, if i > j copy vj to the new adjacency-list of vi , otherwise,
if j > i
DATA STRUCTURES & ALGORITHMS
CS/SE2C03
Introduction
What is an algorithm ?
CS/SE2C03
Introduction
What is an algorithm ?
ALGORITHM
Input Output
CS/SE2C03
Introduction
What is an algorithm ?
ALGORITHM
Input Output
Example: Sorting
Input: Sequence of n numb
Dynamic Programming (DP)
Have we being doing too much work in our recursions?
CS/SE2C03
Dynamic Programming (DP)
Have we being doing too much work in our recursions?
CS/SE2C03
Dynamic Programming (DP)
Solving optimization (maximization or minimization)
pr
Minimum Spanning Trees
Figure: A MST
CS/SE2C03
Minimum Spanning Trees
Figure: A MST
CS/SE2C03
Minimum Spanning Trees
Figure: A cut
CS/SE2C03
Kruskals algorithm
CS/SE2C03
Kruskals algorithm
CS/SE2C03
Kruskals algorithm
CS/SE2C03
Prims algorithm
CS/SE2C03
P
CS/SE 2C03 - Assignment 2 Solution
Kun Hu
1. Exercise 7.2-3
We look at the process of partitioning. If all the elements are already sorted in decreasing
order, each time the partitioning routine will produce one subproblem of size n 1 and the
other of siz
CS/SE 2C03 - Assignment 5 Solution
Filip Jeremic and Kun Hu
1. Exercise 24.2-3
Instead of modifying the DAG-SHORTEST-PATHS procedure, we will modify the structure
of the graph so that we can run DAG-SHORTEST-PATHS on it. Well give a way to transform a PER
Assignment 1
Do the following problems and exercises from the book. Note that the ordering reects
the order in which the relevant material is being covered by the course. Exercises are spread
throughout a chapter, and problems can be found at the end of e
CS/SE 2C03 - Assignment 4 Solution
Adam Lenarcic and Filip Jeremic
1. Exercise 23.1-2
We need to show that though a light edge is safe, it is not necessarily the case that a safe
edge is a light edge. This is simply due to the minimum property of the ligh
CS/SE 2C03 - Assignment 1 Solution
Filip Jeremic
1. Problem 1-1
The rst thing we need to solve this question is to determine the relative length of a
microsecond. A quick search on the web determines the conversions we need:
1 second = 1.0 106 microsecon
CS/SE 2C03 - Assignment 6 Solution
Adam Lenari
cc
1. 25.2-5
(k1)
(k1)
(k1)
The given alternative denition simply modies the association if dij
= dik
+ dkj . We remember that we are only concerned nding with the shortest path, based on total weight of edge
DATA STRUCTURES AND ALGORITHMS
CS/SE 2C03
Instructor
Dr. George Karakostas
ITB/218, ext 26132, Mac address: karakos
Office hours: W 2:30-4:30 pm
Course Assistance
Adam Lenarcic, Mac address: lenarcaj, Rm. ITB/208, Office hours: Th 2:30 - 4:30 pm
Andrew Le