80 likes | 96 Views
Mathematical Preliminaries. The Factorial Function Permutations Logarithms Summations Recurrence Relations Algorithm Analysis. The Factorial Function. Definition: Stirling’s approximation:. Permutations. A permutation of a sequence is the members of a sequence arranged in some order.
E N D
Mathematical Preliminaries • The Factorial Function • Permutations • Logarithms • Summations • Recurrence Relations • Algorithm Analysis
The Factorial Function Definition: Stirling’s approximation:
Permutations • A permutation of a sequence is the members of a sequence arranged in some order. • There are n! different permutations for a sequence with n distinct members. • To generate a permutation of an array:void permute(int *a, int n) { for (int i = n; i > 0; i--) swap(a[i - 1], a[random(i)]); }
Recurrence Relations • For the factorial function: • For the Fibonacci sequence:
Algorithm Analysis • The time T to run an algorithm as a function of n is written as T(n) • T(n) is in the set O(f(n)) if there are two positive constants c and n0 such that • If the upper bound (highest growth rate) for an algorithm is f(n) then it is in O(f(n)) in the worst case • For all inputs that are large enough, the algorithm always executes in less time than
Comparison of Running Timesin Increasing Order O(1) O(log n) O(n) O(n log n) O(nc) O(cn)