Standard Functions and Notations for Algorithm Analysis
Standard Functions and Notations for Algorithm Analysis
Introduction
When analyzing algorithms, we frequently encounter different mathematical functions and notations. Understanding their properties and growth rates is essential for comparing the efficiency of algorithms.
The commonly used functions are
- Monotonic Functions
- Floor and Ceiling Functions
- Modular Arithmetic
- Polynomial Functions
- Exponential Functions
- Logarithmic Functions
- Factorial Function
- Functional Iteration
- Iterated Logarithm
- Fibonacci Numbers
1. Monotonic Functions
A function whose values always increase or always decrease is called a monotonic function.
Monotonically Increasing
If
then
Example
Monotonically Decreasing
If
then
Example
Strictly Increasing
If
then
Example
Strictly Decreasing
If
then
Example
2. Floor and Ceiling Functions
These functions are widely used in Divide-and-Conquer algorithms.
Floor Function
The floor of a real number is the greatest integer less than or equal to the number.
Notation
Example
| x | Floor(x) |
|---|---|
| 3.8 | 3 |
| 7.2 | 7 |
| 5 | 5 |
| -2.3 | -3 |
Ceiling Function
The ceiling of a number is the smallest integer greater than or equal to the number.
Notation
Example
| x | Ceiling(x) |
|---|---|
| 3.2 | 4 |
| 5.9 | 6 |
| 7 | 7 |
| -2.3 | -2 |
Important Properties
for every integer .
Also,
3. Modular Arithmetic
The modulo operator gives the remainder after division.
Notation
Formula
Examples
| Expression | Answer |
|---|---|
| 17 mod 5 | 2 |
| 20 mod 4 | 0 |
| 35 mod 6 | 5 |
Applications
- Hash Tables
- Cryptography
- Circular Queues
- Cyclic Scheduling
4. Polynomial Functions
A polynomial is
where
- are constants
- is the degree.
Examples
Important Result
Only the highest-degree term determines the asymptotic growth.
Example
5. Exponential Functions
General form
where
Examples
Properties
Growth
Exponential functions grow much faster than polynomial functions.
Example
| n | n² | 2ⁿ |
|---|---|---|
| 10 | 100 | 1024 |
| 20 | 400 | 1,048,576 |
6. Logarithmic Functions
Logarithms grow very slowly.
Common notations
Important Rules
Product Rule
Power Rule
Change of Base
Examples
| Expression | Answer |
|---|---|
| log₂8 | 3 |
| log₂32 | 5 |
| log₁₀100 | 2 |
Importance
Many efficient algorithms have
time complexity.
Examples
- Binary Search
- AVL Trees
- Heap Operations
7. Factorial Function
Notation
Definition
Examples
| n | n! |
|---|---|
| 0 | 1 |
| 1 | 1 |
| 3 | 6 |
| 5 | 120 |
| 6 | 720 |
Growth
Factorial grows faster than exponential functions.
Approximation (Stirling's Formula)
Applications
- Counting permutations
- Backtracking algorithms
- Branch and Bound
- Combinatorics
8. Functional Iteration
Repeated application of the same function.
Notation
Example
If
then
9. Iterated Logarithm
Notation
Read as
Log Star of n
It is the number of times logarithm must be applied until the result becomes less than or equal to 1.
Examples
| n | log* n |
|---|---|
| 2 | 1 |
| 4 | 2 |
| 16 | 3 |
| 65536 | 4 |
Importance
This is one of the slowest-growing functions in computer science.
It appears in
- Union-Find algorithms
- Disjoint Set Union (DSU)
- Some advanced graph algorithms
10. Fibonacci Numbers
Defined recursively as
Sequence
Growth
Fibonacci numbers grow approximately as
where
called the Golden Ratio.
Relative Growth of Common Functions
From slowest to fastest growth:
| Growth Rate | Example |
|---|---|
| Constant | |
| Logarithmic | |
| Polylogarithmic | |
| Linear | |
| Linearithmic | |
| Quadratic | |
| Cubic | |
| Polynomial | |
| Exponential | |
| Factorial | |
Comments
Post a Comment