algorithms and complexity Flashcards
what is an algorithm
set of computational steps that transforms an input into an output
why do we study algorithms
to check performance correctness robustness and simplicity
space complexity
the amount of memory required for an algorithm to run to completion
fixed part
the size required to store certain variables that are independent to the size of the problem
variable part
the space needed by variables with their size dependent on the size of the problem
what is the experimental approach of calculating the run time
you can implement the program and input different values to accurately measure the running time them plot a graph from your findings
what are some limitations to the experimental approach
the algorithm must be implemented which can take a long time and can be difficult
to compare two algorithms the same hardware and software must be used which may be difficult
what is an alternative to the experimental approach
operation counting
what does sigma notation do
expresses sums where each term is in the same form
what is the sigma formation for a for loop
b
∑ 1 = b - a + 1
i = a
how do you calculate the average case
sum up all the inputs and divide by the total number of inputs
what is big o notation used for
calculating the growth of functions
what is the order of function growth
constant - log n - n^c (o < c < 1) - n - nlog n - n^2 - n^3 - 2^n - 3^n - n!
what is the formal definition of big o
f(n) = O(g(n)) means there are positive constants c and k, such that 0 ≤ f(n) ≤ cg(n) for all n ≥ k
big o establishes an upper bound for the growth of functions when numbers start to get very large
upper bound
what is the formal definition for big omega (Ω)
provides a lower bound
f(n) is said to be Ω(g (n)) if there exists positive constant C and (n0) such that 0 <= Cg(n) <= f(n) for all n >= n0