Skip to content

HemanthPaila/sorting-visualizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sorting-visualizer

The sorting visualizer is a web application built using HTML, CSS, and JavaScript, which provides a visual representation of various sorting algorithms such as bubble sort, insertion sort, selection sort, quicksort, merge sort, and heap sort. The application allows users to input an array of unsorted numbers, select a sorting algorithm, and visualize the sorting process in real-time.

To implement the real-time visualization, the application uses asynchronous programming techniques such as async/await and setTimeout methods. The async/await keywords create asynchronous functions that allow the application to perform time-consuming tasks such as sorting without blocking the main thread. The setTimeout method is used to introduce a delay in the execution of the sorting algorithm, which allows the application to update the visual representation of the sorting process.

The application also provides control over the size and speed of the input array using range bars. Users can adjust the size of the array to visualize how the sorting algorithms work with different numbers of elements. They can also adjust the speed of the sorting process to slow it down or speed it up for a better visualization of the sorting process.

Each sorting algorithm included in the application has its own time and space complexity. Bubble sort has a time complexity of O(n^2) and a space complexity of O(1), insertion sort has a time complexity of O(n^2) and a space complexity of O(1), selection sort has a time complexity of O(n^2) and a space complexity of O(1), quicksort has a time complexity of O(n log n) and a space complexity of O(log n), merge sort has a time complexity of O(n log n) and a space complexity of O(n), and heap sort has a time complexity of O(n log n) and a space complexity of O(1).

The algorithms are executed step by step, with the application updating the visual representation of the sorting process after each step. Each algorithm is color-coded in the application to help users distinguish between the different sorting methods.

The user interface is designed using HTML and CSS, with JavaScript used to implement the sorting algorithms and update the user interface in real-time. The interface consists of a button that generates an input of unsorted array of numbers, select a sorting algorithm, adjust the size and speed of the array using range bars, and start the sorting process. The application then displays a visual representation of the sorting process, with each step of the process represented graphically using color-coded bars that represent the sorted and unsorted elements.

One unique feature of the application is that once the user generates an array and starts the sorting process, all buttons are disabled to prevent interruptions. After the sorting process is completed, the buttons are enabled again. This ensures that the user can follow the sorting process uninterrupted and obtain accurate results.

In summary, the sorting visualizer is a web application built using HTML, CSS, and JavaScript, which allows users to visualize various sorting algorithms such as bubble sort, insertion sort, selection sort, quicksort, merge sort, and heap sort. The application uses asynchronous programming techniques such as async/await and setTimeout methods to implement real-time visualization of the sorting process. The user interface provides control over the size and speed of the input array using range bars, and the application includes the time and space complexities of the sorting algorithms to help users understand the efficiency of each algorithm.