Big-O growth
Line shape shows growth; the cursor reads the selected input size.
1
5
32
160
1,024
Data Structures & Algorithms
This page only covers the material present in my DSA I notes: Java review, iterator/comparator basics, Big-O, ArrayLists, recursion and binary search, linked lists, stacks, and queues.
Module 0 · Foundations
The notes start by translating Java syntax, generics, wrapper types, Iterable, Iterator, Comparable, and Comparator into concepts familiar from JS/TS.
Module 0 · Big-O
Big-O is treated as the tightest reasonable upper bound for worst-case growth, after dropping constants and lower-order terms.
Module 1
ArrayLists use a backing array, shift elements for middle insert/remove, and resize by copying into a larger array. Recursion needs a base case and progress toward it.
Module 2
Linked lists trade random access for pointer updates. The notes compare SLL, DLL, and CLL edge cases and operation costs.
Module 3
Stacks restrict work to one end. Queues add at the back and remove at the front. ArrayQueue uses a circular array and unwraps on resize.
Line shape shows growth; the cursor reads the selected input size.
1
5
32
160
1,024
Pick an operation, then apply it to watch positions change.
Call factorial(4); it must wait.
Target: 19. 19 > 13, eliminate the left half through mid.
1. low 0, mid 3, high 6: 19 > 13, eliminate the left half through mid.
Stack changes happen at one top end; queue changes enter at back and leave from front.
Stack / LIFO
Queue / FIFO
When the backing array is full, the implementation creates a larger array and copies existing elements before adding new data.
Module 1 · ArrayLists
Each recursive call waits on a smaller call until the base case returns, then results unwind back up the call stack.
Module 1 · Recursion
ArrayQueue keeps a front index. Enqueue lands at (front + size) % capacity; dequeue advances front by one modulo capacity.
Module 3 · Stacks & Queues
Module 0 · Foundations
An Iterator — hasNext() / next(). Implementing Iterable is what lets a type work with it.
Comparable defines the natural order of a type (compareTo); Comparator is an external, swappable ordering rule.
Module 0 · Big-O
The tightest reasonable upper bound on worst-case growth, after dropping constants and lower-order terms.
Not necessarily — constants and lower-order terms are dropped from Big-O but can still matter in practice.
Module 1
addToBack only resizes occasionally; addAtIndex must shift every later element one slot to the right.
A base case plus progress toward it. Binary search halves the search window each step until it is empty.
Module 2
An SLL must walk from head to find the new tail; a DLL reads tail.prev directly.
Keep one pointer to the head and use a data-swap trick so the front and back are both reachable in O(1).
Module 3
Stack is LIFO and works at one end; queue is FIFO — add at the back, remove from the front.
At index (front + size) % capacity — a circular array that unwraps into a larger one on resize.