CSE373 Assignment1

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

[1] [1]

Assignment-1

“Analyzing sorting algorithms in real-world scenarios”

Course Name: Design and Analysis of Algorithms


Course Code: CSE373
Section: 1

Submitted to:
Dr. Sifat Momen (Sfm1)
Associate Professor
Department of Electrical and Computer Engineering

Submitted by:
Shishir Oyshi
ID: 2014334642
ECE Department

Date of Submission: 17/05/2024


1. Implementation:
Insertion Sort:

Merge Sort:

1
Heap Sort:

2
Quick Sort:

3
2. Experimental Analysis
Code
(Generating random datasets representing packages with varying sizes

Sorting each dataset using all four algorithms)

4
Output

(Measuring and recording the execution time of each algorithm for different dataset
sizes)

5
Graph (Execution Time VS Dataset Size)

3. Discussion

Analyzing Results:

Compare the time complexity: Insertion Sort (O(n^2)), Merge Sort (O(n log n)), Heapsort
(O(n log n)), Quicksort (O(n log n) on average, O(n^2) in worst case).

Space complexity: Insertion Sort (O(1)), Merge Sort (O(n)), Heapsort (O(1)), Quicksort
(O(log n) on average due to recursion).

Suitability Analysis:

For small datasets or nearly sorted data, Insertion Sort might be efficient.

For larger datasets, Merge Sort and Heapsort are generally more stable in performance.

6
Quicksort is often faster in practice for average cases but has a worst-case scenario to
consider.

Recommendation:

Given the logistics company's need for efficiency with large datasets, Merge Sort or
Heapsort are likely the best choices due to their consistent O(n log n) performance and
relatively straightforward implementation.

You might also like