Algorithm Analysis
Big Omega
Best case time
Cavets with Big O
In a nutshell, be careful about very large constant factors. Or situations like O(n) = n**100 vs O(n) = 2**n
Linear function. O(n) = n
Like a for-loop function. Note: A linear function also represents the best running time we can hope to achieve for any algorithm that processes each n objects that are not already in computer's memory, because reading the n objects already requires n operations.
N-Log-N function. O(n) = n * log(n)
These functions take longer than linear but less than quadratic. The fastest possible sorting algorithms are n*log(n)
Quadratic function. O(n) = n**2
This often times occurs from nested loops. However, this also occurs if the number of operations increases by one after each iteration. Although as (n* (n+1))/2
Logarithmic function. O(n) = log(n)
When discussing logarithms, we noted that the value is generally not an integer, yet the running time of an algorithm is usually expressed by means of an integer quantity, such as the number of operations performed. Thus, the analysis of an algorithm may sometimes involve the use of thefloor function and ceiling function, which are defined respectively as follows: • x = the largest integer less than or equal to x. • x = the smallest integer greater than or equal to x.
Big O
Worst case run time. Worst case analysis also forces the algorithm to perform well on every input. The overall Big O function can be defined by the operations most expensive step
Algorithm
a step by step procedure for performing some task in a finite amount of time
Data structure
a systematic way of organizing and accessing data
Big Theta
average case time
Exponential function. O(n) = b**2
b a positive constant called the base and the input size is n. For instance, if we have a function that starts by performing one operation and then double the number of operations performed with each iteration
Experimental Analysis Challenges
experimental running times of two algorithms are difficult to directly compare unless it's the same hardware/software environments experiments can only be done on a limited set of test inputs. so running times of inputs not tested are left out algorithm must be fully implemented in order to execute it and study it's running time. however, experimental analysis is still useful for fine-tuning production-quality code
Cubic function. O(n) = n**3
occurs occasionally like a triple nested loop. But otherwise this is higher to represent higher order polynomials
Constant function. O(n) = 1
primitive operations
Primitive operations
•Assigning an identifier to an object •Determining the object associated with an identifier •Performing an arithmetic operation (for example, adding two numbers) •Comparing two numbers •Accessing a single element of a Python list by index •Calling a function (excluding operations executed within the function) •Returning from a function. Formally a primitive operation corresponds to a low-level instruction with an execution time that is constant, although many of the ones here many be translated to a small number of instructions