CS201: Data Structures & Algorithms Notes
Your Name
August 26, 2025
Contents
1 Introduction to Algorithm Analysis 2
1.1 Big-O Notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.2 Example: Linear Search . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
2 Stacks and Queues 2
1
1 Introduction to Algorithm Analysis
1.1 Big-O Notation
Big-O notation describes the upper bound of an algorithm’s growth rate.
• Constant Time: O(1)
• Logarithmic Time: O(log n)
• Linear Time: O(n)
• Quadratic Time: O(n2 )
1.2 Example: Linear Search
Algorithm 1 Linear Search
1: procedure LinearSearch(A[0..n − 1], x)
2: for i ← 0 to n − 1 do
3: if A[i] = x then
4: return i ▷ Element found at index i
5: end if
6: end for
7: return −1 ▷ Element not found
8: end procedure
Time Complexity: O(n) in the worst case.
2 Stacks and Queues