& Algorithms
Complete Study Notes
High School / A-Level • Computer Science • Beginner–Intermediate
Arrays & Lists Stacks & Queues Linked Lists Trees & Graphs Sorting Searching Big-O Notation
What's Inside
✔ Every major data structure explained clearly with diagrams in text
✔ Python code examples for every structure
✔ Big-O complexity tables for quick revision
✔ Sorting & searching algorithms step-by-step
✔ Quick-reference cheat sheet at the end
, 1 | Big-O Notation
Big-O notation describes how the time or space an algorithm needs grows as the input size n increases. It tells you the
worst-case performance, so you can compare algorithms fairly.
Notation Name Example Speed
O(1) Constant Array index lookup ■ Instant
O(log n) Logarithmic Binary search ■ Very fast
O(n) Linear Loop through a list ■ OK
O(n log n) Log-linear Merge sort ■■ Moderate
O(n²) Quadratic Bubble sort ■ Slow
O(2^n) Exponential Recursive Fibonacci ■ Very slow
■ Key rule: Always aim for the lowest complexity you can achieve. O(1) and O(log n) are great; O(n²) should be avoided for
large datasets.
2 | Arrays & Lists
An array (called a list in Python) stores items in a contiguous sequence. Each item has an index starting at 0.
Python Example
nums = [10, 20, 30, 40, 50]
print(nums[0]) # 10 — first element
print(nums[-1]) # 50 — last element
nums.append(60) # add to end
nums.insert(2, 99) # insert 99 at index 2
nums.pop() # remove last element
print(len(nums)) # number of elements
Operation Big-O Notes
Access by index O(1) Direct lookup — instant
Search (linear) O(n) Must check each element
Append O(1) Add to end
Insert at i O(n) Shifts elements right
Delete at i O(n) Shifts elements left