Chapter 4
Optimization II :
Dynamic Programming
Let us try to solve the knapsack problem using a somewhat different strategy. Let
Fi (y) denote the optimal solution for a knapsack capacity y and only using the objects
in cfw_x1 , x2 . . . xi . Under this

mywbut.com
2.2 Analyzing algorithms
Analyzing an algorithm has come to mean predicting the resources that the algorithm requires.
Occasionally, resources such as memory, communication bandwidth, or computer hardware are of primary
concern, but most often

mywbut.com
Chapter 2:
2.1 Insertion sort
We start with insertion sort, which is an efficient algorithm for sorting a small number of elements. Insertion
sort works the way many people sort a hand of playing cards. We start with an empty left hand and the

mywbut.com
2.3 Designing algorithms
There are many ways to design algorithms. Insertion sort uses an incremental approach: having sorted the
subarray A[1 j - 1], we insert the single element A[j] into its proper place, yielding the sorted subarray A[1
j]

Models of Computation
mywbut.com
1
Models of Computation (RAM)
a)
b)
c)
d)
e)
f)
g)
Random Access Machines
Straight Line Programs and Circuits
Vector Machines
Turing Machines
Pointer Machines
Decision Trees
Machines That Make Random Choices
mywbut.com
2
R

mywbut.com
3.1 Asymptotic notation
The notations we use to describe the asymptotic running time of an algorithm are defined in terms of
functions whose domains are the set of natural numbers N = cfw_0, 1, 2, .. Such notations are convenient for
describing

Chapter 9
Graph Algorithms
A number of graph problems use Depth First Search as the starting point. Since it
runs in linear time, it is efficient as well. A DFS yields two distinct numbering of the
vertices based on start-time (when a vertex is first visi