BINARY_SEARCH: DATA_MUST_BE_SORTED
QUICKSORT_PIVOT: PARTITIONING
HASH_COLLISION: SEPARATE_CHAINING
STATE: OPTIMIZING_ACCESS
ASKiIMAN™ DOOR 04 / THE CODE / REALM 07
--:-- · -- --- ----

Ontological Layer: Data Retrieval and Ordering

Searching & Sorting

Algorithms for Organizing the Chaos

The Imperative of Order

Data structures only hold information; algorithms make that information usable. To find a single element among millions requires strategy. We search linearly by brute force, or logarithmically by exploiting sorted order. We create that order by sorting—swapping, selecting, or dividing and conquering. And when pure speed is demanded, we abandon sequential search entirely, using Hashing to calculate the exact address of the data we seek.

UNORDERED DATA → O(N²) SORTS (BUBBLE/INSERTION) → O(N LOG N) SORTS (MERGE/QUICK) → SORTED DATA → BINARY SEARCH vs HASH MAPPING → O(1) RETRIEVAL

The 13 Algorithmic Nodes

Ontological Mapping: Strategies of Retrieval and Arrangement

GROUP 01

Linear Search

  • Sequential, element-by-element check
  • Requires no specific data order
  • O(N) worst-case time complexity
  • General purpose but slow for large sets
GROUP 01

Binary Search

↓
  • Requires strictly sorted data
  • Divides search space in half each step
  • Low, Mid, and High pointers
  • O(log N) worst-case efficiency
GROUP 02

Bubble Sort

  • Adjacent element comparisons
  • Swaps if out of order
  • Largest elements "bubble" to the end
  • O(N²) complexity, simple but inefficient
GROUP 02

Selection Sort

  • Scans for absolute minimum/maximum
  • Places extreme at the front/end
  • Shrinks the unsorted boundary
  • O(N²) complexity, fewer swaps than bubble
GROUP 02

Insertion Sort

  • Maintains a sorted prefix region
  • Takes next item, shifts larger items right
  • Inserts into correct sorted position
  • Efficient for nearly sorted data O(N)
GROUP 03

Merge Sort

  • Divide and Conquer paradigm
  • Recursively split array into halves
  • Merge sorted halves back together
  • Guaranteed O(N log N) complexity
GROUP 03

Quick Sort

  • Selects a Pivot element
  • Partitions into [ < Pivot ] and [ > Pivot ]
  • Recursively sorts partitions
  • Fastest in practice, O(N²) worst-case
GROUP 03

Heap Sort

1
3
  • Converts array into a Max/Min Heap
  • Extracts extreme element to array end
  • Restores heap property (Heapify)
  • In-place O(N log N) sort
GROUP 04

Hashing Concept

  • Bypasses sequential comparison
  • Hash function computes direct index
  • Key → Hash(Key) → Table Address
  • Goal is O(1) constant retrieval time
GROUP 04

Hash Collisions

  • Two distinct keys map to same index
  • Inevitable due to limited table size
  • Load Factor = Items / Table Size
  • Necessitates resolution strategies
GROUP 04

Separate Chaining

  • Each table index holds a Linked List
  • Colliding keys are appended to the list
  • Graceful degradation under high load
  • Requires dynamic memory allocation
GROUP 04

Open Addressing

  • All elements stored directly in table
  • Linear Probing (Check next adjacent slot)
  • Quadratic Probing (Check i² slots away)
  • Double Hashing (Use second hash func)
FINAL PROTOCOL

13 — Searching & Sorting Laboratory

1. BINARY_SEARCH: mid = (low + high)/2
2. QUICKSORT: pivot = arr[high], partition()
3. HASH: index = key % table_size
[1] TRACE SORTS [2] CALCULATE MIDPOINTS [3] IDENTIFY PIVOTS [4] RESOLVE COLLISIONS [5] ANALYZE EFFICIENCY

These algorithms dictate how software handles volume. A poor sort choice brings a system to a halt; a good hash function makes retrieval instantaneous. Understanding exactly *why* Merge Sort outpaces Bubble Sort leads directly into the next logical step: Realm 08 and the formal Mathematics of Efficiency.

SIMULATION RUNNING