Linear & Searching ParadigmsPhase 1

Stage 1 of 5
Foundational Mental Model

Linear & Searching Paradigms

Why this lesson right now?Adaptive Pedagogy

You encountered memory indexing and boundary traps in recent problem attempts. This 20-minute interactive module directly targets those exact gaps before advancing to downstream tree and graph traversals.

### The Search Problem Given a collection of elements and a target value $T$, determine if $T$ exists and at which index.

1. Linear Search (Unsorted Data) - **Mechanism**: Inspect every element from index $0$ to $N - 1$. - **When to Use**: When data is completely unsorted or streaming. - **Time Complexity**: $O(N)$ worst/average case.

2. The Power of the "Sorted" Invariant - When data is pre-sorted, sequential checking is wasteful. - By examining the **middle element**, we can discard half the remaining search space with a single comparison!

Time Complexity
Linear: O(N) | Binary: O(log N)
Space Complexity
Iterative: O(1)