Models of Computation: Analysis of Algorithms Week 1, Lecture 2
Models of Computation: Analysis of Algorithms Week 1, Lecture 2
Analysis of Algorithms
Week 1, Lecture 2
Prepared by
Readings
Main Reading Selection:
CLR, Chapter 1 and 2
RAM Assumptions
1) Each register holds an integer
2) Program cant modify itself
3) Memory instructions involve simple
arithmetic
a) Addition, subtraction
b) Multiplication, division and control
states (got, if-then, etc.)
Complexity Measures of
Algorithms
Input X
size n=|X|
=> Algorithm A
=>
output
Complexity Measures of
Algorithms (contd)
Worst case
time complexity
Cost Criteria
Uniform Cost Criteria
Time = # RAM instructions
space = # RAM memory registers
Logarithmic Cost Criteria
Time= L(i) units per RAM instruction
on integer size i
Space = L(i) units per RAM register
on integer size i
where L(i) =
i0
i0
Example
Z 2
for k=1 to n do Z Z Z
ouput Z = 2
2n
Uniform
Logarithmic
time cost = n
time cost > 2n
Varieties of Computing
Machine Models
RAMs
Straight line programs
Circuits
Bit vectors
Lisp machines
Turning Machines
Example
Given polynomial
input X
Y an
for i = n-1 by -1 to 0 do Y (Y X) + a i
ouput Y
Example (contd)
Straight
Line
Programs
Circuits
1-1
correspondence
Restrictions
1) All memory registers have value 0 or 1
2) Use only logical operations
and
or
parity
not
Vector Machines
logical operations , ,
vector elements
applied to
Decision Trees
Pointer Machines
Based on LISP programming
language
= max steps of TM
Proof idea
Read
write
memory
Extensions of RAMS
Reasonable:
(0) Modifiable Program
(1) Random Choices
(2) Non-uniformity
Not Reasonable:
(3) Non-deterministic Choices
RASP Machine
Same as RAM but allow
program to change itself
Same power as RAM
Proof idea (due to Von Neumann)
Let RAM use memory registers to
store modifiable program of RASP
Randomized Machines
Extend RAM instructions to include
r RANDOM(k) gives a random k
bit number
Let AR(x) denote randomized
algorithm with input x, random
choices R
P
R
O
B
A
B
I
L
I
T
Y
TIME
T(n)
A Randomized Computation
Non-Uniformity
For each input size n, allow the program
a distinct, finite, advice tape to read
Note:
If advice tape length 2n can solve any
Boolean output problem with n
Boolean inputs (obvious).
a non-uniform deterministic
algorithm with polynomial time and
polynomial advice!
Gives way of derandomizing a
randomized algorithm
Nondeterministic Machines
Allow nondeterministic choice branches
accept x
reject x
NP and P
NP = languages accepted by
polynomial time nondeterministic TM
machines.
Includes many hard problems:
1) Traveling Salesman Problem
2) Propositional Satisfiability
3) Integer Programming
P = languages accepted by
polynomial time deterministic
machines
?
Not known
P = NP probably no
Conclusion
1) There are many possible machine
models
2) Most (but not Nondeterministic) are
constructable so might be used if
we have efficient algorithms to
execute on machines.
3) New machine models can help us
invent new algorithms, and vice versa!
Models of Computation
Analysis of Algorithms
Week 1, Lecture 2
Prepared by