Sorting Report
Sorting Report
Class: BSAI-5th.
Quicksort:
A divide-and-conquer algorithm that partitions an array around a pivot and recursively sorts the
subarrays.
Method:
Heapsort:
A comparison-based sorting algorithm that uses a binary heap data structure to repeatedly extract
the maximum (or minimum) element.
Method:
Insertion Sort:
A simple sorting algorithm that builds the final sorted array one element at a time by inserting
each element into its correct position.
Time complexity: n2
Method:
Counting Sort:
A non-comparison-based sorting algorithm that counts the occurrences of each element and uses
these counts to place elements in the correct order.
Time complexity: n
Method:
• Count Frequencies: Count the occurrences of each element and store them in a count
array.
• Calculate Positions: Update the count array to store the cumulative positions of elements.
• Place Elements: Place each element in its correct position in the output array based on the
count array.
• Copy Output: Copy the sorted elements back into the original array.
Frontend.html:
This file contains frontend html involved in creating the display.
Frontend.css:
This file contains all the styling for the html file.
Frontend.js:
This file contains js code for buttons and labels, connecting it with other js files. It also contains
the code to generate the array as well as displaying it.
Table:
Time is in milliseconds
Size Quicksort Insertion Counting HeapSort
10 0.20 0.10 0.20 0.40
20 0.10 0 0.10 0.10
25 0.20 0 0.20 0.10
30 0.40 0.20 0.60 0.90
33 0.20 0.20 0.30 0.50
35 0.10 0 0.10 0.30
40 0.10 0.10 0.10 0.30
45 0.30 0.20 0.20 0.50
50 0.10 0.10 0.10 0.20
60 0.10 0.10 0.20 0.50
• Quicksort performs best overall with consistently low execution times across all input
sizes.
• Insertion Sort is efficient for smaller or partially sorted inputs but is not reliable for
larger sizes.
• Counting Sort is efficient but shows a performance spike for size 30.
• Heap Sort is the slowest overall and does not scale as well as Quicksort for larger inputs.
Display: