Professional Documents
Culture Documents
Ch4. Algorithms Note
Ch4. Algorithms Note
Algorithms
4.1 Introduction
1. 𝑙𝑎𝑟𝑔𝑒 = 𝑎
Sorting
✓ Ex. Sort numbers stored in array [1, 3, 2, 6, 10, 1, 20]
Randomized algorithms
✓ Ex. Shuffle numbers stored in array [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
Space complexity
✓ (memory) space required to execute the algorithm
Best-case time/space
Worst-case time/space
Average-case time/space
If 𝑓 𝑛 = 𝑂 𝑔 𝑛 and 𝑓 𝑛 = Ω 𝑔 𝑛 ,
𝑓 𝑛 = Θ(𝑔 𝑛 )
Example 4.3.6
𝑓 𝑛 = log 𝑏 𝑛
Example 4.3.8
𝑓 𝑛 = 1𝑘 + 2𝑘 + ⋯ + 𝑛𝑘 with some 𝑘 ∈ 𝐍
𝑓𝑘 = 𝑓𝑛+2 − 1 , ∀𝑛 ≥ 1
𝑘=1