SortingAlgorithmComplexity

# SortingAlgorithmComplexity - Algorithm Complexity Written...

This preview shows pages 1–3. Sign up to view the full content.

Algorithm Complexity Written and composed by Laurent Haan http://www.progressive-coding.com Introduction to Algorithm Complexity [...] an algorithm is a procedure (a finite set of well-defined instructions) for accomplishing some task which, given an initial state, will terminate in a defined end-state. The computational complexity and efficient implementation of the algorithm are important in computing, and this depends on suitable data structures. Wikipedia: http://en.wikipedia.org/wiki/Algorithm In Computer Science, it is important to measure the quality of algorithms, especially the specific amount of a certain resource an algorithm needs. Examples of such resources would be time or memory storage. Nowadays, memory storage is almost a non-essential factor when designing algorithms but be aware that several systems still have memory constraints, such as Digital Signal Processors in embedded systems. Different algorithms may complete the same task with a different set of instructions in less or more time, space or effort than other. The analysis and study of algorithms is a discipline in Computer Science which has a strong mathematical background. It often relies on theoretical analysis of pseudo-code. To compare the efficiency of algorithms, we don't rely on abstract measures such as the time difference in running speed, since it too heavily relies on the processor power and other tasks running in parallel. The most common way of qualifying an algorithm is the Asymptotic Notation, also called Big O.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Asymptotic Notation The symbol O is used to describe an asymptotic upper bound for the magnitude of a function in terms of another, simpler function. This means that for x > k, when x tends to infinity, the value f(x) will always be inferior to C *g(x) (with C a constant). The idea behind this notation is that it allows us to qualify to efficiency of an algorithm by telling us how often a certain algorithm will execute operations before terminating. Let's start with a simple example: void f ( int a[], int n ) { int i; printf ( "N = %d\n", n ); for ( i = 0; i < n; i++ ) printf ( "%d ", a[i] ); printf ( "\n" ); } In this function, the only part that takes longer as the size of the array grows is the loop. Therefore, the two printf calls outside of the loop are said to have a constant time complexity, or O(1), as they don't rely on N. The loop itself has a number of steps equal to the size of the array, so we can say that the loop has a linear time complexity, or O(N). The entire function f has a time complexity of 2 * O(1) + O(N), and because constants are removed, it's simplified to O(1) + O(N). Now, asymptotic notation also typically ignores the measures that grow more slowly because eventually the measure that grows more quickly will dominate the time complexity as N moves toward infinity. So by ignoring the constant time complexity because it grows more slowly than the linear time complexity, we can simplify the asymptotic bound of the function to O(N), so the conclusion is that f has linear time
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 10/24/2009 for the course ECE 3090 taught by Professor Staff during the Fall '08 term at Georgia Tech.

### Page1 / 9

SortingAlgorithmComplexity - Algorithm Complexity Written...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online