You are on page 1of 8

Green University of Bangladesh

Department of Computer Science and Engineering (CSE)


Faculty of Sciences and Engineering
Semester: (Summer, Year:2021), B.Sc. in CSE (Day)

Lab Report NO #03


Course Title: Data Structure Lab
Course Code: CSE 106 Section:D2

Lab Experiment Name: Implementation of Bubble Sort, Selection Sort and Insertion
Sort

Student Details

Name ID

Md.Al-Rouman 223002036

Lab Date : 18/10/2023


Submission Date : 24/10/2023
Course Teacher’s Name : Tamim Al Mahmud

Lab Report Status


Marks: ………………………………… Signature:.....................
Comments:.............................................. Date:..............................
1. TITLE OF THE LAB REPORT EXPERIMENT
Implementation of Bubble Sort, Selection Sort and Insertion Sort

2.OBJECTIVES/AIM [2 marks]
This study aims to enhance the efficiency of fundamental sorting algorithms - bubble sort, insertion sort,
and selection sort. The focus is on optimizing these algorithms, evaluating their strengths and
weaknesses, and identifying areas for improvement. The goals include understanding their computational
complexities, space and time efficiencies, and adaptability to different datasets. The study also explores
error handling mechanisms and algorithmic modifications to enhance reliability. Additionally, it
investigates the impact of dataset characteristics on algorithm performance and demonstrates the
practical significance of these optimized sorting techniques in real-world applications.
2. PROCEDURE / ANALYSIS / DESIGN [3 marks]

Flowchart of bubble sort:


Flowchart of insertion sort:
Flowchart of selection sort:

IMPLEMENTATION [3 marks] Overview:


Bubble Sort: Bubble sort is a simple sorting algorithm that repeatedly steps through the list, compares
adjacent elements, and swaps them if they are in the wrong order. The process is repeated for each element
until the list is sorted. Its implementation involves iterating through the list multiple times,comparing
adjacent elements, and swapping them if necessary. Although straightforward, bubble sort is not the most
efficient algorithm for large datasets due to its quadratic time complexity.

Insertion Sort: Insertion sort is a sorting algorithm that builds the final sorted list one item at a time. It is
much less efficient on large lists than more advanced algorithms such as quicksort, heapsort, or merge
Selection sort:selection sort is a straightforward and intuitive sorting Algorithms. The algorithm works by
dividing the input list into two parts: the sorted and the unsorted sublists. The sorted sublist is initially
empty, while the unsorted sublist contains all the elements. The algorithm repeatedly selects the smallest
(or largest, depending on the order) element from the unsorted sublist and swaps

5. TEST RESULT / OUTPUT [3 marks]


Bubble sort code and output:
Insertionsortcode:
Output;

Selection sort code and output:


6. ANALYSIS AND DISCUSSION [3 marks]
So here in discussion we can see in Bubble sort, insertion sort, and selection sort are basic sorting
methods, each with distinct features. Bubble sort compares adjacent elements and swaps them if they are
in the wrong order. Insertion sort builds a sorted list by inserting elements sequentially. Selection sort
selects the smallest element and places it in the sorted sublist. While these algorithms are easy to
understand, their quadratic time complexities make them inefficient for large datasets. More advanced
sorting algorithms like merge sort and quicksort, with O(n log n) time complexities, are preferred for
larger datasets due to their efficiency. However, bubble sort, insertion sort, and selection sort remain
useful for educational purposes and small datasets due to their simplicity

You might also like