Matrix Multiplication: Geometry, Dot Products, and Transformations
Master matrix multiplication through row-by-column dot products, dimensional compatibility rules, and interactive visual step tracing.
Understand the logarithmic efficiency of binary search, its strict sorted-array precondition, interval halving mechanics, and edge case implementations.
low (beginning of active interval) and high (end of active interval). At each iteration, we compute the midpoint:Calculating mid using low + (high - low) / 2 prevents integer overflow in languages with fixed-width integers (e.g. Java, C++).
array[mid] === target, search succeeds immediately and returns mid.array[mid] < target, the target must reside in the upper half. We discard the left half by setting low = mid + 1.array[mid] > target, the target must reside in the lower half. We discard the right half by setting high = mid - 1.low > high, the search space has shrunk to zero elements. The target is not present.array[4] = 16 < 23. Target must be in the right half. Adjusting low = mid + 1 (5).
export function binarySearch<T>(arr: T[], target: T): number {
let low = 0;
let high = arr.length - 1;
while (low <= high) {
// Avoid (low + high) / 2 overflow in 32-bit environments
const mid = low + Math.floor((high - low) / 2);
const midVal = arr[mid];
if (midVal === target) {
return mid; // Target found
} else if (midVal < target) {
low = mid + 1; // Narrow to right half
} else {
high = mid - 1; // Narrow to left half
}
}
return -1; // Target does not exist
}Iterative implementation of binary search returning target index or -1.
Master interval halving mechanics, logarithmic recurrence relations, pointer boundaries, and real-world systems applications with spaced repetition.
Foundational research, standard mathematical treatises, and verified peer-reviewed literature supporting this topic.
Jeffrey D. Karpicke & Janell R. Blunt (2011). Science, 331(6018), 772–775.
Demonstrates that retrieval practice outperforms elaborative concept mapping for conceptual retention and inferential problem solving.
Does not imply concept mapping is without value; hierarchical mapping excels at organizing domain schemas, but active retrieval is required to retain them.
The standard algorithms reference text with formal divide-and-conquer recurrences.
Master matrix multiplication through row-by-column dot products, dimensional compatibility rules, and interactive visual step tracing.
Explore how the slope of secant lines converges to the tangent line as the interval shrinks to zero, establishing the fundamental definition of the derivative.