Live Pseudocode
The highlighted line matches the current visualization step.
MaxMin(A, l, r):
if l == r:
return (A[l], A[l])
if r == l + 1:
if A[l] < A[r]:
return (A[l], A[r])
else:
return (A[r], A[l])
mid = ⌊(l + r)/2⌋
(min1, max1) = MaxMin(A, l, mid)
(min2, max2) = MaxMin(A, mid+1, r)
return ( min(min1, min2), max(max1, max2) )
Tip: Watch how ranges shrink to size 1 or 2 (base cases), then merge back up.
DnC vs Naive (Comparisons)
Comparison Counter
DnC (this run): 0
Naive scan: 0 (≈ 2(n−1))
Show Naive Result
—
Complexity (Quick Visual)
Estimated comparisons
Naive ≈ 14 comparisons
DnC ≈ 10 comparisons (about 3n/2 − 2)
Meaning: DnC reduces comparisons by doing fewer “max checks” and fewer “min checks” overall.