Analysis and Design of Algorithms
Analysis and Design of Algorithms
SESSION TOPICS
1)Graphs:
➔ Graph algorithms.
➔ Depth-first search.
➔ Breadth-first search;
➔ Directed Graphs;
➔ Shortest paths;
➔ Network flowGraphs;
Weeks-10,11,12 1
GRAPHS
A graph can be viewed as a collection of points in the plane
called “vertices” or “nodes,” some of them connected by line
segments called “edges” or “arcs.”
Weeks-10,11,12 3
GRAPHS
It is normally convenient to label vertices of a graph or a digraph
with letters, integer numbers, or, if an application calls for it,
character strings. The graph depicted below has six vertices and
seven undirected edges: (A)
V = {a, b, c, d, e, f },
E = {(a, c), (a, d), (b, c), (b, f ), (c, e), (d, e), (e, f )}.
The digraph depicted has six vertices and eight directed
edges(B): V = {a, b, c, d, e, f },
E = {(a, c), (b, c), (b, f ), (c, e), (d, a), (d, e), (e, c), (e, f )}.
B:DIRECTED(DIGRAPH)
A: UNDIRECTED Weeks-10,11,12 4
GRAPHS
We disallow multiple edges between the same vertices of
an undirected graph
The number of edges |E| possible in an undirected graph with |V|
vertices and no loops:
0 ≤ |E| ≤ |V |(|V | − 1)/2.
Sparse graph: one with few edges relative to the number of its
vertices.
Denseness or sparseness may influence how to represent the
graph and, the running time of an algorithm being designed.
Weeks-10,11,12 5
GRAPHS
Graph Representations
Two ways are used:
the adjacency matrix
adjacency lists.
The adjacency matrix: a graph with n vertices is an n × n boolean
matrix with one row and one column for each of the graph’s
vertices, in which the element in the ith row and the j th column
is equal to 1 if there is an edge from the i th vertex to the jth
vertex, and equal to 0 if there is no such edge. For undirected
graph is adjacency matrix always symmetric, i.e., A[i, j ] = A[j, i]
for every 0 ≤ i, j ≤ n − 1
The adjacency lists: of a graph or a digraph is a collection of
linked lists, one for each vertex, that contain all the vertices
adjacent to the list’s vertex (i.e., all the vertices connected to it
by an edge). Usually, such lists start with a header identifying a
vertex for which the list is compiled.
Weeks-10,11,12 6
GRAPHS
Graph Representations: adjacency matrix; adjacency lists.
Weeks-10,11,12 7
GRAPHS
Weighted graph (or weighted digraph): is a graph (or di-
graph) with numbers assigned to its edges.
These numbers are called weights or costs (benefits).
Relevance in real life: real-world applications like shortest path
in a transportation; communication network or the traveling
salesman problem.
Weeks-10,11,12 8
GRAPHS
Weighted graph (or weighted digraph): is a graph
Weeks-10,11,12 9
GRAPHS: PATHS AND CYCLES
Path: a path from vertex u to vertex v of a graph G can be
defined as a sequence of adjacent (connected by an edge)
vertices that starts with u and ends with v.
Simple Path: all vertices of a path are distinct.
Length of a path: is the total number of vertices in the vertex
sequence defining the path minus 1, which is the same as the
number of edges in the path.
A directed path: is a sequence of vertices in which every
consecutive pair of the vertices is connected by an edge
directed from the vertex listed first to the vertex listed next.
Connected graph: every pair of its vertices u and v there
is a path from u to v.
Cycle: is a path of a positive length that starts and ends at
the same vertex and does not traverse the same edge more
than once. For example, f , h, i, g, f is a cycle for earlier graph.
Acyclic graph: has no cycles
Weeks-10,11,12 10
GRAPHS: PATHS AND CYCLES
A Hamiltonian cycle of a directed graph G = (V, E) is a simple
cycle that contains each vertex in V .
Determining whether a directed graph has a Hamiltonian cycle
is NP-complete.
A cut (S, V - S) of an undirected graph G = (V, E) is a partition of
V.
A cut in a connected graph is a subset E’ of edges such
that G \ E’ is not connected. Here, G \ E’ is a short-hand for (V,
E \ E’ ). If S is a set of nodes with ∅ ≠ S ≠ V , the set of edges
with exactly one endpoint in S forms a cut.
Weight of a cut is the number of edges crossing the cut.
A cut respects a set A of edges if no edge in A crosses the
cut.
An edge is a light edge crossing a cut if its weight is the
minimum of any edge crossing the cut.
More generally, we say that an edge is a light edge satisfying a
given property if its weight is the minimum of any edge
Weeks-10,11,12 11
satisfying the property.
GRAPHS: PATHS AND CYCLES
A clique in an undirected graph G = <V, E> is a subset V’ ≤ V of
vertices, each pair of which is connected by an edge in E.
Weeks-10,11,12 12
GRAPHS
Graph algorithms: Depth-first search.
A graph’s traversal begins at an arbitrary vertex by marking
it as visited.
Each iteration: the algorithm proceeds to an unvisited vertex
that is adjacent to the one it is currently in.
If there are several such vertices, a tie can be resolved
arbitrarily (max, larger, smaller, alphabetical, etc).
This process continues until a dead end - a vertex with no
adjacent unvisited vertices is encountered.
At a dead end, the algorithm backs up one edge to the vertex
it came from and tries to continue visiting unvisited vertices
from there. The algorithm eventually halts after backing up
to the starting vertex, with the latter being a dead end.
By then, all the vertices in the same connected component
as the starting vertex have been visited.
If unvisited vertices still remain, the depth-first search must
be restarted at any one of them.
Weeks-10,11,12 13
GRAPHS
Graph algorithms: Depth-first search.
Weeks-10,11,12 15
GRAPHS
Graph algorithms: Depth-first search.
DFS(G)
//Implements a depth-first search traversal of a given graph
//Input: Graph G = V , E
//Output: Graph G with its vertices marked with consecutive integers
// in the order they are first encountered by the DFS traversal
mark each vertex in V with 0 as a mark of being “unvisited”
count ← 0
for each vertex v in V do
if v is marked with 0 then dfs(v)
//----------------------------------------------------------------
dfs(v)
//visits recursively all the unvisited vertices connected to vertex v
//by a path and numbers them in the order they are encountered
//via global variable count
count ← count + 1; mark v with count
for each vertex w in V adjacent to v do
if w is marked with 0 then dfs(w)
Weeks-10,11,12 16
GRAPHS
Graph algorithms: Depth-first search
Weeks-10,11,12 17
GRAPHS
Graph algorithms: Depth-first search
Weeks-10,11,12 18
GRAPHS
Graph algorithms: Breadth-first search
● Proceeds by visiting first all the vertices that are adjacent
to a starting vertex
● Then visit all unvisited vertices two edges apart from it,
and so on, until all the vertices in the same connected
component as the starting vertex are visited.
● If there still remain unvisited vertices, the algorithm has to
be restarted at an arbitrary vertex of another connected
component of the graph.
● It is convenient to use a queue to trace the operation of
breadth-first search.
● The queue is initialized with the traversal’s starting vertex,
which is marked as visited.
● On each iteration, the identify all unvisited vertices that are
adjacent to the front vertex, mark them as visited, and add
them to the queue; after that, the front vertex is removed
from the queue Weeks-10,11,12 19
GRAPHS
Graph algorithms: Breadth-first search
Traversal queue,
with numbers
indicating the
BFS forest with tree and
order in which
the vertices are cross edges shown with
Graph solid and dotted lines,
visited, i.e.,
added to (and respectively.
removed from)
the queue.
Weeks-10,11,12 20
GRAPHS
Graph algorithms: Breadth-first search
BFS(G)
//Implements a breadth-first search traversal of a given graph
//Input: Graph G = V , E
//Output: Graph G with its vertices marked with consecutive integers
//in the order they are visited by the BFS traversal
mark each vertex in V with 0 as a mark of being “unvisited”
count ← 0
for each vertex v in V do
if v is marked with 0 then bfs(v)
//------------------------------------------------------------
bfs(v)
//visits all the unvisited vertices connected to vertex v
//by a path and numbers them in the order they are visited
//via global variable count
count ← count + 1; mark v with count and initialize a queue with v
while the queue is not empty do
for each vertex w in V adjacent to the front vertex do
if w is marked with 0
count ← count + 1; mark w with count
Weeks-10,11,12 21
add w to the queue
remove the front vertex from the queue
GRAPHS
Graph algorithms: Breadth-first search
Weeks-10,11,12 22
GRAPHS
Graph algorithms: Breadth-first search
Weeks-10,11,12 23
GRAPHS
Directed Graphs:Shortest Paths
Dijkstra’s Algorithm
The single-source shortest-paths problem:
For a given vertex called the source in a weighted connected graph, find
shortest paths to all its other vertices.
We are not interested here in a single shortest path that starts at the
source and visits all the other vertices. This coud be a version of of the
traveling salesman problem
Weeks-10,11,12 27
GRAPHS
Directed Graphs:Shortest Paths
Dijkstra’s Algorithm
The single-source shortest-paths problem:
Ties are broken arbitrarily.
After we have identified a vertex u∗ to be added to the
tree, we need to perform
two operations
1)Move u∗ from the fringe to the set of tree vertices.
2)For each remaining fringe vertex u that is connected
to u∗ by an edge of weight w(u∗ , u) such that du∗ +
w(u∗ , u) < du , update the labels of u by u∗ and du∗ +
w(u∗ , u), respectively.
Weeks-10,11,12 28
GRAPHS
Directed Graphs:Shortest Paths
Dijkstra’s Algorithm
Weeks-10,11,12 29
GRAPHS
Directed Graphs:Shortest Paths
Dijkstra’s Algorithm
Weeks-10,11,12 30
GRAPHS
Directed Graphs:Shortest Paths
Dijkstra’s Algorithm
Declare all nodes unscanned and initialized and parent
while there is an unscanned node with tentative distance < +∞ do
u:= the unscanned node with minimal tentative distance
relax all edges (u, v) out of u and declare u scanned
Weeks-10,11,12 31
GRAPHS
Directed Graphs:Shortest Paths
Dijkstra’s Algorithm
Weeks-10,11,12 32
GRAPHS
Directed Graphs:Shortest Paths
Dijkstra’s Algorithm
Weeks-10,11,12 33
GRAPHS
Directed Graphs:Minimum Spanning Trees
Consider a connected undirected graph G = (V, E) with real
edge costs c: E → R+ .
A minimum spanning tree (MST) of G is defined by:
a set T ⊆ E of edges such that the graph (V, T) is a tree
c(T ) := ∑e∈T c(e) is minimized.
Weeks-10,11,12 34
GRAPHS
Directed Graphs:Minimum Spanning Trees
Minimum spanning trees (MSTs) are perhaps the simplest
variant of an important family of problems known as network
design problems.
MSTs show up in many seemingly unrelated problems such as
clustering, finding paths that minimize the maximum edge cost
used, or finding approximations for harder problems.
Weeks-10,11,12 35
GRAPHS
Directed Graphs:Minimum Spanning Trees
The Jarník-Prim (JP) algorithm for MSTs
● Starting from an (arbitrary) source node s, the JP algorithm
tree and the cut E’ is the set of edges with exactly one
endpoint in S.
● A minimum cost edge leaving S is added to the tree in
every iteration.
● The main challenge is to find this edge efficiently. To this
encodes v ┐∈ S.
● This action saves space and a comparison in the innermost
loop.
● Observe that c(e) < d[v] is only true if d[v] > 0, i.e., v ┐∈ S,
Weeks-10,11,12 37
GRAPHS
Directed Graphs:Minimum Spanning Trees
The Jarník-Prim (JP) algorithm for MSTs
Application of Prim’s
algorithm. The
parenthesized labels
of a vertex in the
middle column
indicate the nearest
tree vertex and edge
weight; selected
vertices and edges are
shown in bold.
Weeks-10,11,12 39
GRAPHS
Directed Graphs:Minimum Spanning Trees
The Jarník-Prim (JP) algorithm for MSTs
Weeks-10,11,12 40
GRAPHS
Directed Graphs:Minimum Spanning Trees
The Jarník-Prim (JP) algorithm for MSTs
Weeks-10,11,12 41
GRAPHS
Directed Graphs:Minimum Spanning Trees
The Jarník-Prim (JP) algorithm for MSTs
Weeks-10,11,12 42
GRAPHS
Directed Graphs:Minimum Spanning Trees
KRUSKAL’S ALGORITHM
● This is an alternative algorithm.
● It needs no sophisticated graph representation, but
● already works when the graph is represented by its list of
edges.
● For sparse graphs with m = O(n), its running time is
competitive with the JP algorithm.
● It scans over the edges of G in order of increasing cost and
maintains a partial MST T ; T is empty initially.
● The algorithm maintains the invariant that T can be
extended to an MST.
● When an edge e is considered, it is discarded or added to
the MST.
● The decision depends on the cycle or cut property. The
endpoints of e either belong to the same connected
component of (V, T ) or not.
Weeks-10,11,12 43
GRAPHS
Directed Graphs:Minimum Spanning Trees
Kruskal’s Algorithm
It is essential that edges are considered in order of
increasing cost. Therefore e can be discarded by the cycle
property.
It is essential that edges are considered in order of
increasing cost.
We may also add e to T by the cut property. The invariant is
maintained.
It can be implemented very efficiently so that the main cost
factor is sorting the edges. This takes time O(m log m) if we
use an efficient comparison-based sorting algorithm.
The constant factor involved is rather small so that for
m = O(n)
It may be possible to do better than the O(m + nlog n) JP
algorithm.
Weeks-10,11,12 44
GRAPHS
Directed Graphs:Minimum Spanning Trees
Kruskal’s Algorithm
Weeks-10,11,12 46
GRAPHS
Directed Graphs:Minimum Spanning Trees
Kruskal’s Algorithm
Application of
Kruskal’s
algorithm.
Selected
edges are
shown in
bold.
Weeks-10,11,12 47
GRAPHS
Directed Graphs:Minimum Spanning Trees
Kruskal’s Algorithm
Shaded edges belong to the forest A being grown. Each edge is sorted order by weight.
Weeks-10,11,12 48
An arrow points to the edge under consideration at each step of the algorithm. If the
GRAPHS
Directed Graphs:Minimum Spanning Trees
Kruskal’s Algorithm
Weeks-10,11,12 49
DIRECTED GRAPHS: NETWORK FLOW GRAPHS
We look at the important problem of maximizing the flow of a
material through a transportation network (pipeline system,
communication system, electrical distribution system, and
so on).
Flow Network (or network)
We represent the transportation network by a connected
weighted digraph with n vertices numbered from 1 to n and a
set of edges E, with the following properties:-
1)It contains exactly one vertex with no entering edges; this
vertex is called the source and assumed to be numbered 1.
2)It contains exactly one vertex with no leaving edges; this
vertex is called the sink and assumed to be numbered n.
3)The weight uij of each directed edge (i, j ) is a positive
integer, called the edge capacity. (This number represents
the upper bound on the amount of the material that can be
sent from i to j through a link represented by this edge.)
Weeks-10,11,12 50
DIRECTED GRAPHS: NETWORK FLOW GRAPHS
Let the amount sent through edge (i, j ) by xij , then for any
intermediate vertex i, the flow-conservation
requirement can be expressed by the following equality
constraint (total outflow from source=total inflow into sink=value of flow):
∑xji = ∑xij for i = 2, 3, . . . , n − 1,
j : (j,i)∈E x ij i: (I,j)∈E x ij
Weeks-10,11,12 52
DIRECTED GRAPHS: NETWORK FLOW GRAPHS
maximize v = ∑x1j
i: (1,j)∈E
subject to
∑xji - ∑xij = 0 for i = 2, 3, . . . , n − 1,
j : (j,i)∈E x ij i: (I,j)∈E for every edge (i, j ) ∈ E.
value and try to find an augmenting path for the new flow.
If no flow-augmenting path can be found, we conclude
that the current flow is optimal.
●
Weeks-10,11,12 54
DIRECTED GRAPHS: NETWORK FLOW GRAPHS
Weeks-10,11,12 55
DIRECTED GRAPHS: NETWORK FLOW GRAPHS
Illustration of the
augmenting-path
method. Flow-
augmenting paths
are
shown in bold. The
flow amounts and
edge capacities are
indicated by
the numbers before
and after the slash,
respectively
Weeks-10,11,12 56
DIRECTED GRAPHS: NETWORK FLOW GRAPHS
Weeks-10,11,12 58
GENERAL PROBLEM CLASSES
POLYNOMIAL (P) PROBLEM CLASS
A decision problem is a problem that can be posed as a yes-
no question of the input values.
An example of a decision problem is deciding whether a
given natural number is prime.
Another is the problem "given two numbers x and y, does x
evenly divide y?".
The answer is either 'yes' or 'no' depending upon the values
of x and y.
Weeks-10,11,12 59
GENERAL PROBLEM CLASSES
POLYNOMIAL (P) PROBLEM CLASS
Problems for which a deterministic polynomial time
algorithm exists belong to the complexity class P, which is
central in the field of computational complexity theory.
Polynomial time can be said to be "tractable", "feasible",
"efficient", or "fast".
Some examples of polynomial time algorithms:
● Selection sort algorithm on n integers performs in O(n2)
● Basic arithmetic operations (addition, subtraction, multiplication,
division, and comparison);
● Maximum matchings in graphs;
● Computing the product and the greatest common divisor
● of two integers;
● Sorting a list; searching for a pattern in a text string; checking
connectivity and acyclicity of a graph;
● Finding a minimum spanning tree;
● Finding shortest paths in a weighted graph.
Weeks-10,11,12 60
GENERAL PROBLEM CLASSES
POLYNOMIAL (P) PROBLEM CLASS
Class P is a class of decision problems that can be solved in
polynomial time by (deterministic) algorithms. This class of
problems is called polynomial.
Weeks-10,11,12 61
GENERAL PROBLEM CLASSES
POLYNOMIAL (P) PROBLEM CLASS
Not every problem can be solved in polynomial time.
Problems with exponentially large output cannot be solved
in polynomial but exponential time. Example is generating
subsets of a given set or finding all the permutations of n
distinct items. There are many important problems are not
decision problems in their most natural formulation can be
reduced to a series of decision problems that are easier to
study. For example, the minimum number of colors needed
to color the vertices of a graph so that no two adjacent
vertices are colored the same color.
Some decision problems cannot be solved at all by any algorithm.
Such problems are called undecidable, as opposed to decidable
problems that can be solved by an algorithm. Example is halting
problem: given a computer program and an input to it, determine
whether the program will halt on that input or continue working
indefinitely on it. Weeks-10,11,12 62
GENERAL PROBLEM CLASSES
POLYNOMIAL (P) PROBLEM CLASS
More problems that cannot be solved in polynomial time
● Hamiltonian circuit problem: Determine whether a given
Weeks-10,11,12 64
GENERAL PROBLEM CLASSES
POLYNOMIAL (P) PROBLEM CLASS
Not every problem can be solved in polynomial time.
Problems with exponentially large output cannot be solved
in polynomial but exponential time. Example is generating
subsets of a given set or finding all the permutations of n
distinct items.
There are many important problems are not decision
problems in their most natural formulation can be reduced to
a series of decision problems that are easier to study.
For example, the minimum number of colors needed to color
the vertices of a graph so that no two adjacent vertices are
colored the same color.
Weeks-10,11,12 65
GENERAL PROBLEM CLASSES
NON DETERMINISTIC POLYNOMIAL (NP) PROBLEM CLASS
Most decision problems are in NP. This class includes all the
problems in P : P ⊆ NP.
Examples: Hamiltonian circuit problem, the partition prob-
lem, decision versions of the traveling salesman, the
knapsack, graph coloring, and many hundreds of other
difficult combinatorial optimization problems
Non-example: the halting problem
Weeks-10,11,12 67
GENERAL PROBLEM CLASSES
NP-COMPLETE PROBLEM CLASS
An NP-complete problem is a problem in NP that is as
difficult as any other problem in this class because, by
definition, any other problem in NP can be reduced to it in
polynomial time.
A decision problem D1 is said to be polynomially reducible to
a decision problem D2 , if there exists a function t that
transforms instances of D1 to instances of D2 such that:
1. t maps all yes instances of D1 to yes instances of D2 and
all no instances of D1 to no instances of D2
2. t is computable by a polynomial time algorithm
NP-complete problems
Hamiltonian circuit; traveling salesman; partition; bin
packing; and graph coloring.
Weeks-10,11,12 69
GENERAL PROBLEM CLASSES
NP-COMPLETE PROBLEM CLASS
Notion of an NP-
complete problem.
Polynomial-time
reductions of NP
problems to an
NP-complete
problem are
shown by arrows
Weeks-10,11,12 70
GENERAL PROBLEM CLASSES
NP-COMPLETE PROBLEM CLASS Proving NP-
completeness by
reduction
NP-completeness
implies that if there
exists a deterministic
polynomial-time
algorithm for just one
NP-complete problem,
then every problem in
NP can be solved in
polynomial time by a
deterministic algorithm,
and hence P = NP.
But is P = NP ? (exercise
to ponder)
Weeks-10,11,12 71
GENERAL PROBLEM CLASSES
SATISFIABILITY
Boolean Satisfiability (SAT) Problem:
Given a boolean expression in conjunctive form, decide
whether it has a satisfying assignment. A boolean expression
in conjunctive form (CF) is a conjunction C1 ∧ C2 ∧ . . . ∧ Ck
of clauses.
A clause is a disjuntion l1 ∨ l2 ∨ . . . ∨ lh of literals and a literal
is a variable or a negated variable. So x1 ∨ ¬x3 ∨ ¬x9 is a
clause.
Weeks-10,11,12 72
GENERAL PROBLEM CLASSES
SATISFIABILITY- CNF = CONJUCTIVE NORMAL FORM
2-CNF satisfiability vs. 3-CNF satisfiability:
● A boolean formula contains variables whose values are 0 or 1;
boolean connectives such as ∧(AND), v (OR),
● And : ¬ (NOT); and parentheses. A boolean formula is satisfiable
if there exists some assignment of the values 0 and 1 to its
variables that causes it to evaluate to 1.
● A boolean formula is in k-conjunctive normal form, or k-CNF, if it
is the AND of clauses of ORs of exactly k variables or their
negations. For example, the boolean formula
● (x1 v ¬ x2 ) ∧ (¬ x1 v x3) ∧ (¬ x2 v ¬ x3) is in 2-CNF. It has the
satisfying assignment x1 = 1; x2 = 0; x3 = 1.
● We can determine in polynomial time whether a 2-CNF formula is
satisfiable; however determining whether a 3-CNF formula is
satisfiable is NP-complete.
Weeks-10,11,12 73
GENERAL PROBLEM CLASSES
SATISFIABILITY- CNF = CONJUCTIVE NORMAL FORM
3-CNF satisfiability example- 3 variable in ():
(x1 ∨ x2 ∨ y1 ) ∧ (x3 ∨ y2 ∨ ¬y1 ) ∧… ∧(xn-2 ∨ yn-3 ∨¬yn-4 ) ∧( xn-1 xn ¬yn-3 )
Look for values of x1, x2, .., xn and y1, y2, .. yn that make the
expression true. This is NP problem.
Weeks-10,11,12 74
GENERAL PROBLEM CLASSES
SATISFIABILITY- CNF = CONJUCTIVE NORMAL FORM
3-CNF satisfiability example- 3 variable in ():
(x1 ∨ x2 ∨ y1 ) ∧ (x3 ∨ y2 ∨ ¬y1 ) ∧… ∧(xn-2 ∨ yn-3 ∨¬yn-4 ) ∧( xn-1 xn ¬yn-3 )
The reduction
algorithm
begins with an
instance of 3-
CNF-SAT. Let
D= C1 ∧ C2
∧ .. ∧ Ck be a
boolean
formula in 3-
CNF with k
clauses.
Weeks-10,11,12 75
GENERAL PROBLEM CLASSES
NP-HARD PROBLEM CLASS
● A problem is NP-hard if an algorithm for solving it can be
translated into one for solving any NP-problem
(nondeterministic polynomial time) problem. NP-hard
therefore means "at least as hard as any NP-problem,"
although it might, in fact, be harder.
● A problem is said to be NP-hard if everything in NP can be
transformed in polynomial time into it, and a problem is NP-
complete if it is both in NP and NP-hard.
● The NP-complete problems represent the hardest problems
in NP.
● There are no known polynomial-time algorithms for these
problems, and there are serious theoretical reasons to
believe that such algorithms do not exist.
Weeks-10,11,12 76
GENERAL PROBLEM CLASSES: NP-HARD PROBLEM CLASS
Weeks-10,11,12 79
CSC 311 DESIGN AND ANALYSIS OF ALGORITHMS
REFERENCES
1)Levitin, Anany (2012). Introduction to the design & analysis of
algorithms / Anany Levitin. 3rd ed. Pearson. ISBN-13: 978-0-13-
231681-1, ISBN-10: 0-13-231681-1.
2)Kurt Mehlhorn and Peter Sanders(2007). Algorithms and Data
Structures. The Basic Toolbox.
3)Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest,
Clifford Stein (2009). Introduction to algorithms, Third Edition.
4)Dasgupta, C. H. Papadimitriou, and U. V. Vazirani (2006).
Algorithms.
5)The Design and Analysis of Computer Algorithms, Aho,
Hopcroft and Ullman
6)Internet Resources.
Weeks-10,11,12 80