Design technique, like divide-and-conquer.
Example: Longest Common Subsequence (LCS)
Given two sequences x[1 . . m] and y[1 . . n], find
a longest subsequence common to them b
John D. Carter
901 12th Avenue
Seattle, WA 98122
telephone: (206) 296-5956
fax: (206) 296-5932
The class of context-free languages generalizes over the class of regular languages, i.e.,
every regular language is a context-free language.
The reverse of this is not true, i.e., every context-free language is not necessarily
Median, Order Statistics
Select the i th smallest of n elements (the
element with rank i).
i = 1: minimum;
i = n: maximum;
i = (n+1)/2 or (n+1)/2: median.
Naive algorithm: Sort and index i th element.
Worst-case running time
Greedy Algorithms, Graphs,
Minimum Spanning Trees
Definition. A directed graph (digraph)
G = (V, E) is an ordered pair consisting of
a set V of vertices (singular: vertex),
a set E V V of edges.
In an undirected graph G = (V,
Shortest Paths II: BellmanFord, Topological Sort, DAG
Shortest Paths, Linear
Recall: If a graph G = (V, E) contains a negativeweight cycle, then some shortest paths may not exist.
Augmenting Data Structures,
Dynamic Order Statistics,
Dynamic order statistics
OS-SELECT(i, S): returns the i th smallest element
in the dynamic set S.
OS-RANK(x, S): returns the rank of x S in the
sorted order of Ss elements.
Shortest Paths I: Properties,
Paths in graphs
Consider a digraph G = (V, E) with edge-weight
function w : E R. The weight of path p = v1
v2 L vk is defined to be
w( p) w(vi , vi 1 ) .
Red-black Trees, Rotations,
Balanced search trees
Balanced search tree: A search-tree data
structure for which a height of O(lg n) is
guaranteed when implementing a dynamic
set of n items.