0 - Introduction
note: this is not an exact, formal definition
A computational problem
We often specify a problem by a predicate
Given an Input output space
Note that while a problem may specify many correct outputs for a given input, a correct algorithm maps an input to exactly one of the correct outputs, for that input.
Let
Moreover, the family of functions
In general, a model of computation, is a collection of operations that a computer can preform in
A word is block of
Memory is an addressable contiguous sequence of words. each word in memory, is also addressable by some word.
A processor, is an abstract entity that supports many constant time operations on a block of
- Given a word
, it can read the word at address . it can write a word to the address . - It's important that every word in the memory is addressable by some word. Suppose our memory is a sequence of
words. then, we can simply address it as . But each of these numbers must be in binary, hence, we would need bits to address every word-block in memory, which means that our word size must grow at least as fast as , that is . - It can also perform integer and bitwise arithmetic, as well as logical operations.
An interface is a collection of objects
The birthday problem:
Given a set of
def bithday (People,n)
Number the collection of people from 1 to n
make an empty record
for i in range (1,n)
put birthday(i) in record
for j < i
if birthday(i) == birthday(j)
return pair(i,j)
exit
put birthday(j) in record
We will almost never use this type of pseudocode ever.