Models of Computation
Models of Computation
mywbut.com 1
Models of Computation (RAM)
mywbut.com 2
Random Access Machine (RAM)
mywbut.com 3
RAM Assumptions
mywbut.com 4
Simplified Program Style
mywbut.com 5
Complexity Measures of Algorithms
Input X
⇒ Algorithm A ⇒ output
size n=|X|
{x:|x|=n}
mywbut.com 7
Cost Criteria
• Uniform Cost Criteria
Time = # RAM instructions
space = # RAM memory registers
mywbut.com 8
Cost Criteria (cont’d)
• Example
Z←2
for k=1 to n do Z ← Z ⋅ Z
2n
ouput Z = 2
Uniform time cost = n
Logarithmic time cost > 2n
mywbut.com 9
Varieties of Computing Machine
Models
RAMs
Straight line programs
Circuits
Bit vectors
Lisp machines
…
Turning Machines
mywbut.com 10
Straight Line Programs
• Idea
• fix n = input size
• unroll each iteration loop until result
is loop-free program Πn
• Note: this is only possible if we can
eliminate all branching and all indirect
addressing
mywbut.com 11
Example
• Given polynomial
mywbut.com 13
Straight Line
Programs ⇐⇒ Circuits
1-1
correspondence
mywbut.com 14
Boolean Circuits (for VLSI Design)
• Restrictions
1) All memory registers have value 0 or 1
2) Use only logical operations
∧ ∨ ⊕ ¬
“and”
mywbut.com
“or” “parity” “not” 15
Vector Machines
• logical operations ∧, ∨, ⊕, ¬
• applied to vector elements
mywbut.com 16
Vector Machines (cont’d)
• Example
graph G
mywbut.com 17
Decision Trees
mywbut.com 18
Decision Trees (cont’d)
• To sort n keys
• Any decision tree must have
n! output leaves
• (n! = # permutations of n keys)
hence height of tree is
mywbut.com 19
Pointer Machines
Based on LISP programming language
my m 20
The Turing Machine (TM):
The VW of Machines
mywbut.com 21
The Turing Machine (cont’d)
mywbut.com 22
Reductions Between TM and RAM
Models
1) Given TM time cost T(n) then
∃ equivalent RAM (obvious)
Time c T(n) if uniform
cost
cost c T(n) (log n) if logarithmic
cost
mywbut.com 23
Reductions Between TM and RAM
Models (cont’d)
Proof idea
registers
Read
write
memory
mywbut.com 24
Extensions of RAMS
• Reasonable:
(0) Modifiable Program
(1) Random Choices
(2) Non-uniformity
• Not Reasonable:
(3) Non-deterministic Choices
mywbut.com 25
RASP Machine
mywbut.com 26
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
Expected Time input X
= ∑ Time (X) Prob (R)
Time (X) ∀R
mywbut.com 27
P
R
O
B
A
B
I
L
I
T
Y
TIME T(n)
mywbut.com 28
A Randomized Computation
mywbut.com 29
1) If machine outputs value v with prob >
½ then v is considered its output.
mywbut.com 30
Non-Uniformity
• Note:
• If advice tape length 2n can solve
any Boolean output problem with n
Boolean inputs (obvious).
mywbut.com 31
Surprising Result (Adelman)
mywbut.com 32
Nondeterministic Machines
• Allow “nondeterministic choice” branches
accept x reject x
• 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
mywbut.com 34
Another Surprising Result (Levin)
mywbut.com 35
Conclusion
mywbut.com 36