Repository navigation
[32/N] Add unit tests for BubbleSort, CocktailSort, SelectionSort, InsertionSort, MergeSort, Quicksort, Quickselect, and HeapSort algorithms - #123
Open
karkir0003 wants to merge 32 commits into
Conversation
…de, and AnimatedCircularlyLinkedListNode
…ttern matching algorithms
…Sort, MergeSort, Quicksort, Quickselect, and HeapSort algorithms
This was referenced Oct 3, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Stack
Addresses #93
Context
Adds comprehensive unit test coverage for comparison-based sorting algorithms and order-statistic selection visualizers:
BubbleSort.js: Standard bubble sort with adjacent comparisons, swap counter tracking, early termination pass check, and last-swap optimization toggle (toggleLastSwap).CocktailSort.js: Bidirectional cocktail shaker sort with alternating forward and backward bubbling passes, dual last-swap boundary tracking, and early termination.SelectionSort.js: In-place selection sort with minimum scanning, candidate element tracking, swap execution, and min/max variant selection callback (minCallback/maxCallback).InsertionSort.js: Insertion sort with sorted partition expansion, element shifting, key insertion animation, and comparison/swap metric updates.MergeSort.js: Recursive divide-and-conquer merge sort visualizer with sub-array block splitting, tree level hierarchy display, and merged array reconstruction.Quicksort.js: Quicksort with pivot selection modes (Random, First, Last), two-pointer partition scanning, pivot placement, and recursive boundary sorting.Quickselect.js: Quickselect order-statistic selection finding the k-th smallest element via partitioned pivot pruning, branch selection, and index target validation.HeapSort.js: In-place heap sort combining binary heap tree visualization and array representation, bottom-up max-heap construction (siftDown), and extract-max sorting passes.Changes Made
src/algo/__tests__/BubbleSort.test.js:lastSwap,data).src/algo/__tests__/CocktailSort.test.js:src/algo/__tests__/SelectionSort.test.js:src/algo/__tests__/InsertionSort.test.js:src/algo/__tests__/MergeSort.test.js:src/algo/__tests__/Quicksort.test.js:src/algo/__tests__/Quickselect.test.js:kindex boundaries.run(list, k)execution with partition pruning directly to the target element.k,data).src/algo/__tests__/HeapSort.test.js:heapArrayData,heapArrayID,heapTreeObj).siftDown), extract-max passes, and sorted tree animation.Test Plan
npm test -- --watchAll=false(all 8 new test suites pass, 86 unit tests passing; 68 suites, 765 tests passing repository-wide).npm run lintandnpm run prettier(0 errors, 0 warnings).