0 - Introduction

Computational problem

note: this is not an exact, formal definition
A computational problem P is a relation PI×O from an Input space I to an output space O, such that the input output pair ioP only if o is the correct output for i.

We often specify a problem by a predicate P where o is the correct output for i if P(i,o) is true.

Deterministic Algorithm

Given an Input output space I,O and a problem P, an algorithm is a function f:IO. The algorithm f solves the problem P: if P(i,f(i)) is true for each iI.

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.

Asymptotic Notation

Let H be a family of functions from SR. for f,gH, f=O(g) if for each sS, f(s)Cg(s) for some C>0.
f=Ω(g) if g=O(f).
f=Θ(g) if f=O(g) and g=O(f).
Moreover, the family of functions {f:f(s)Cg(s)} is the class of all functions that are O(g). In such cases, we write fO(g).

Word-RAM model of computation

In general, a model of computation, is a collection of operations that a computer can preform in O(1) time. Along with models of memory and so on. (this is oversimplified)
A word is block of w bits.
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 O(1) words:

  • Given a word a, it can read the word at address a. it can write a word to the address a.
  • It's important that every word in the memory is addressable by some word. Suppose our memory is a sequence of n words. then, we can simply address it as 1,2,,n. But each of these numbers must be in binary, hence, we would need log2(n) bits to address every word-block in memory, which means that our word size must grow at least as fast as log2(n), that is w=Ω(log(n)).
  • It can also perform integer and bitwise arithmetic, as well as logical operations.
Interface, Data structure

An interface is a collection of objects A, and a collection of operations Op(A). A data structure, is a way to store the objects A, and a collection of algorithms, which supports each operation in Op(A).

The birthday problem:

Given a set of n people, return a pair (i,j) if i and j have the same birthday:


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.