Analysis of Algorithms Flashcards
A set of steps to accomplish a task
Algorithm
2 things we want from a computer algorithm
Correctness
Efficient Resource Usage (CPU, Memory)
The theoretical study of computer-program performance and resource usage.
Analysis of Algorithms
An algorithm that gives a correct solution but takes a long time might
be of little to no value.
Time Complexity
Algorithms can be analyzed base on ________ and _________ complexities
Time and Space
_____________ is the primary measure of efficiency.
Time
Factors that can affect runtime
speed of the computer
programming language
compiler/interpreter
other programs running
2 Types of Run Time Analysis
Empirical and Theoretical Analysis
Implement the algorithm, then run with a timer.
Empirical Analysis
We determine how long the algorithm takes as a function of the
size of its input: T(n).
Theoretical Analysis
We focus on how fast the function that
characterizes the running time _______ with the input size.
grows
We focus on how fast the function that characterizes the running time grows with the input size.
Theoretical Analysis
Upper Bound
O-notation (Big O)
is used to describe the upper bound or the maximum possible running time of the algorithm.
The O- notation
O(g(n)) is a set of functions f(n) such
that there exists positive constants c and n0
such that 0 ≤ f(n) ≤ cg(n) for all n ≥ n0