# sort_algo_versua **Repository Path**: vax52/sort_algo_versua ## Basic Information - **Project Name**: sort_algo_versua - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-08-01 - **Last Updated**: 2025-08-02 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Sorting Algorithm Visualizer An interactive web application that visualizes popular sorting algorithms with step-by-step animations. ## Demo [demo](example.gif) ## Features - **9 Sorting Algorithms**: Bubble, Selection, Insertion, Merge, Quick, Heap, Shell, Counting, and Radix Sort - **Interactive Controls**: Start, pause, reset, and adjust sorting speed - **Visual Representation**: Bars represent array elements with height proportional to values - **Real-time Animation**: Watch each algorithm's step-by-step process - **Responsive Design**: Works on desktop and mobile devices ## Algorithms Included ### 1. **Bubble Sort** - O(n²) **How it works:** Repeatedly steps through the list, compares adjacent elements and swaps them if they're in the wrong order. Each pass "bubbles" the largest element to the end of the unsorted portion. - **Best case:** O(n) when already sorted - **Average/Worst case:** O(n²) - **Space complexity:** O(1) ### 2. **Selection Sort** - O(n²) **How it works:** Divides the array into sorted and unsorted portions. Repeatedly finds the minimum element from the unsorted portion and swaps it with the first unsorted element. - **Always:** O(n²) comparisons - **Space complexity:** O(1) - **Stable:** No ### 3. **Insertion Sort** - O(n²) **How it works:** Builds the sorted array one element at a time by taking each element and inserting it into its correct position among the previously sorted elements. - **Best case:** O(n) when nearly sorted - **Average/Worst case:** O(n²) - **Space complexity:** O(1) - **Stable:** Yes ### 4. **Merge Sort** - O(n log n) **How it works:** Divide-and-conquer algorithm that recursively splits the array into halves until single elements remain, then merges sorted halves back together in order. - **Always:** O(n log n) - **Space complexity:** O(n) - **Stable:** Yes - **Parallelizable:** Yes ### 5. **Quick Sort** - O(n log n) **How it works:** Picks a "pivot" element and partitions the array into elements less than pivot and greater than pivot. Recursively sorts the partitions. - **Average case:** O(n log n) - **Worst case:** O(n²) when poorly pivoted - **Space complexity:** O(log n) due to recursion - **Stable:** No (can be made stable with extra work) ### 6. **Heap Sort** - O(n log n) **How it works:** Builds a max heap from the array, then repeatedly extracts the maximum element and places it at the end of the sorted portion. - **Always:** O(n log n) - **Space complexity:** O(1) - **Stable:** No - **In-place:** Yes ### 7. **Shell Sort** - O(n log² n) **How it works:** Generalization of insertion sort that allows exchange of items far apart. Uses diminishing gap sequences to improve efficiency. - **Best case:** O(n log n) - **Average case:** O(n log² n) - **Space complexity:** O(1) - **Stable:** No ### 8. **Counting Sort** - O(n + k) **How it works:** Counts the occurrences of each distinct element, then calculates the positions of each element in the sorted output. - **Time complexity:** O(n + k) where k is the range of input - **Space complexity:** O(n + k) - **Stable:** Yes - **Non-comparison sort:** Works on integers ### 9. **Radix Sort** - O(d × (n + k)) **How it works:** Sorts integers by processing individual digits. Uses counting sort as a subroutine to sort by each digit from least significant to most. - **Time complexity:** O(d × (n + k)) where d is number of digits - **Space complexity:** O(n + k) - **Stable:** Yes - **Non-comparison sort:** Works on integers ## Getting Started ### Prerequisites - A modern web browser (Chrome, Firefox, Safari, Edge) - No additional software or dependencies required ### Running the Application 1. Clone or download this repository 2. Open `index.html` in your web browser 3. Select an algorithm and click "Start Sorting" ## Usage 1. **Select Algorithm**: Choose from the dropdown menu 2. **Adjust Speed**: Use the speed slider to control animation speed 3. **Generate New Array**: Click "Generate New Array" for random data 4. **Control Playback**: Use Start/Pause/Reset buttons as needed ## File Structure ``` sort_algo_versual/ ├── index.html # Main HTML file ├── css/ │ └── styles.css # Styling and animations ├── js/ │ ├── algorithms.js # Sorting algorithm implementations │ ├── visualizer.js # Visualization logic │ └── app.js # Main application controller └── README.md # This file ``` ## Technologies Used - HTML5 - CSS3 (Flexbox, Grid, Animations) - Vanilla JavaScript (ES6+) - No external dependencies ## Browser Compatibility - Chrome 60+ - Firefox 55+ - Safari 11+ - Edge 79+ ## Contributing Feel free to submit issues, fork the repository, and create pull requests for any improvements. ## License This project is open source and available under the [MIT License](LICENSE).