String Matching (Chapter 32)
Text T with N characters Pattern P with M characters The problem: decide whether T has a substring equal to P. Example
kdja;dlkjkaljdfkdjaie4nvoienflkajoienlcjoehahlek kd
Implementing Kruskal's algorithm
How to determine whether adding an edge will cause a cycle? Observation: During the execution of the algorithm, the set of edges in the solution (red edges) forms a se
Another application of DFS: Strongly connected components (Ch22.5)
Consider any directed graph G. For any two vertices a, b, let u v denote the fact that there is a directed path from u to v. Let u,
Graph algorithms (Ch.22) Graphs: Set of OBJECTS with pairwise CONNECTIONS Design and analysis of graph algorithms is a challenging branch of computer science. There are hundreds of graph algorithms kn
Dynamic Programming
An efficient way to implement some
divide-and-conquer algorithms
CS0250, Set 4
Problem with divide-and-conquer
Usually, a direct implementation of a divide-and-conquer
algorithm i
Divide and Conquer Divide
Given some problem, divide it into a number of similar, but smaller sub-problems. Solve each of these problems recursively.
Conquer (or Combine)
Combine the solutions of eac
Overview of some basic algorithms design techniques
1. Greedy heuristics 2. Divide and Conquer 3. Dynamic programming
CS0250, Set 2
Greedy heuristics How to be greedy?
At every step, make the best
What is an algorithm? An algorithm is a sequence of precise and concise instructions that guide you (or a computer) to solve some specific problem. Examples: cooking recipe, VCR trouble shooting instr
Linear Programming
A general way for solving problem
What is a linear program (LP)?
maximize 5 x1 4 x2 3x3 subject to 2 x1 3x2 4 x1 x2 3x1 4 x2 x3 2 x3 5
or equivalently
minimize - 5 x1 4 x2 3x3 sub
Overview of NP-completeness
Definition: A polynomial time algorithm is an algorithm whose running time is no more than a polynomial on the input size. We agree that
An algorithm is an efficient algor
Approximation algorithms (Ch.35)
Polynomial-time algorithms that always return "near-optimal" solutions
An example
The vertex-cover (VC) problem
A vertex cover of an undirected graph G=(V, E ) is a