β‘ Divide & Conquer Algorithm Visualizer An interactive, browser-based visualizer for eight classic Divide & Conquer algorithms. Each algorithm includes a live animation, recurrence relation, time complexity, space complexity, and a plain-language description β all updating instantly when you switch algorithms.
π Project Structure Divide_Conquer_Visualizer/ βββ index.html # HTML structure and layout βββ style.css # All styling, theming, and animations βββ script.js # Algorithm logic, step recording, and rendering No build tools, no dependencies, no installation required. Just open index.html in any modern browser.
π Getting Started
Download or clone the project folder. Make sure all three files (index.html, style.css, script.js) are in the same directory. Open index.html in a browser (Chrome, Firefox, Edge, or Safari). Select an algorithm, click βΊ Generate Data, then click βΆ Start.
π§ Algorithms Covered AlgorithmTypeRecurrenceTime ComplexityMerge SortSortingT(n) = 2T(n/2) + Ξ(n)Ξ(n log n)Quick SortSortingT(n) = T(k) + T(nβkβ1) + Ξ(n)Ξ(n log n) avgMin & MaxArrayT(n) = 2T(n/2) + Ξ(1)Ξ(n)Maximum SubarrayArrayT(n) = 2T(n/2) + Ξ(n)Ξ(n log n)Matrix MultiplicationMatrixT(n) = 8T(n/2) + Ξ(nΒ²)Ξ(nΒ³)Strassen's AlgorithmMatrixT(n) = 7T(n/2) + Ξ(nΒ²)Ξ(n^2.807)Closest Pair of PointsGeometricT(n) = 2T(n/2) + Ξ(n log n)Ξ(n log n)Convex HullGeometricT(n) = 2T(n/2) + Ξ(n)Ξ(n log n)
π¨ Visualization Types Bar Chart β used by Merge Sort, Quick Sort, Min & Max, and Maximum Subarray. Color states during animation: ColorMeaningDark blueUnsorted / untouchedMedium blueActive range being processedYellowTwo elements being comparedRedPivot element (Quick Sort)GreenConfirmed sorted position SVG Canvas β used by Closest Pair of Points and Convex Hull. Renders points on a coordinate grid with connecting lines, divide lines, and hull polygons drawn directly in SVG. Matrix Tables β used by Matrix Multiplication and Strassen's Algorithm. Displays Matrix A, Matrix B, and the computed result side by side, with result cells highlighted.
πΉοΈ Controls ControlDescriptionAlgorithm dropdownSelects the algorithm and immediately updates the info panelβΊ Generate DataCreates a fresh random dataset for the selected algorithmSpeed slider (1β10)Controls animation speed; 1 is slowest, 10 is fastestβΆ StartRuns the algorithm on the current dataset
π Info Panel The right sidebar updates automatically whenever you change the algorithm and shows: ** Algorithm name** Description β plain-language explanation of how the divide & conquer strategy works Recurrence Relation β the exact recurrence (e.g. T(n) = 2T(n/2) + Ξ(n)) Time Complexity β derived from the recurrence via the Master Theorem Space Complexity β auxiliary space used by the algorithm
π§ Implementation Notes
Merge Sort β Records all compare and set operations before animating, enabling smooth replay at any speed. Correctly copies all remaining elements after the main merge loop. Quick Sort β Uses last-element pivot with Lomuto partition scheme. Pivot is highlighted in red throughout its partition phase. Min & Max β Uses β€ 3n/2 β 2 comparisons (more efficient than the naive 2n β 2). Maximum Subarray β Implements the full three-case D&C approach: left half, right half, and crossing subarray. Strassen's Algorithm β Fully implements the 7-product formula (MββMβ), not standard matrix multiplication. Convex Hull β Uses Andrew's monotone chain algorithm (O(n log n)). Closest Pair β Brute-force for the demo dataset size (n = 20), with the divide line visualized.