Computational Complexity: used to study the algorithm efficiency framework for solving specific problems x
Model of computation: allowed operations (allowable operations)
Cost Model: Operation counts)
Upper Bound (Upper Bound): maximum cost
Lower Bound (Lower Bound): Minimum Cost
Optimal Algorithm: The most probable cost algorithm (algorithm with best possible cost guarantee for X)
Example: Sorting
Computing Model: Decision Tree)
The height of the decision tree determines the time consumed.
Cost Model: Compares)
Upper Bound: The merge order is nlgn.
Lower Bound: nlgn
Optimal Algorithm: Merge Sorting (the upper time bound of mergesort reaches the lower time bound of the sorting algorithm, but mergesort consumes too much memory)
Factors Affecting sorting complexity
- Start order of input
- If the input is more ordered, we may not need to compare the nlgn times (in the case of sequential order, insert sort only needs to compare N-1 times)
- Repeated Element
- If the input contains repeated elements, we may not need to compare the nlgn times (3-way quicksort ))
- Digital properties of keys: We can use digital/feature comparison (digit/character compares) instead of key compares to compare numbers and strings.
Princeton University algorithm course algorithm part I week 3 sorting algorithm complexity sorting complexity