Binary Search
Descrizione
Demonstrates binary search on a sorted array of 16 numbers searching for the value 42. Each step highlights the middle element, eliminates half the array, and a step counter shows the logarithmic efficiency versus linear search.
Binary Search
Description
Demonstrates binary search on a sorted array of 16 numbers searching for the value 42. Each step highlights the middle element, eliminates half the array, and a step counter shows the logarithmic efficiency versus linear search.
Phases
| # | Phase Name | Duration | Description |
|---|---|---|---|
| 1 | Title Card | 3s | Title fades in |
| 2 | Array Setup | 4s | 16 sorted boxes appear with values |
| 3 | Linear Search Contrast | 5s | Brief: linear scans all 16 cells |
| 4 | Binary Search Step 1 | 5s | Mid = index 7 (value 35), 42 > 35, eliminate left half |
| 5 | Binary Search Step 2 | 5s | Mid = index 11 (value 55), 42 < 55, eliminate right |
| 6 | Binary Search Step 3 | 5s | Mid = index 9 (value 42), FOUND! |
| 7 | Step Counter Comparison | 5s | 3 steps (binary) vs 16 steps (linear) shown |
| 8 | O(log n) Formula | 4s | MathTex O(log n) explanation |
| 9 | Outro | 2s | Fade out |
Layout
+------------------------------------------------------+
| Binary Search |
+------------------------------------------------------+
| |
| Sorted array (16 elements): |
| [ 2| 5| 9|14|18|23|29|35|42|49|55|61|68|74|81|90]|
| [0][1][2][3][4][5][6][7][8][9]... |
| |
| Step 1: mid=7, arr[7]=35, target=42 → go RIGHT |
| ████████[mid=35]░░░░░░░░░░░░░░░░░░░░ |
| |
| Step 2: mid=11, arr[11]=55, target=42 → go LEFT |
| ░░░░[mid=55]████████████ |
| |
| Step 3: mid=9, arr[9]=42 → FOUND! ✓ |
| |
| Steps: 3 vs Linear: up to 16 |
| O(log n) O(n) |
+------------------------------------------------------+
Area Descriptions
- Top: Title
- Center: Array row; eliminated halves are dimmed/greyed
- Below array: Step description text
- Bottom: Complexity comparison and formula
Assets & Dependencies
- Fonts: LaTeX / sans-serif
- Manim version: ManimCE 0.19.1
Notes
- Eliminated cells fade to dim grey
- Active search range has bright borders
- Middle element flashes orange when evaluated
- "FOUND!" cell turns green with a pop animation
Pubblico: High SchoolCategoria: Cs