0% found this document useful (0 votes)
47 views

Data Structure Using C (2) New Done

The document discusses selection sort and bubble sort algorithms. It provides flowcharts and C code implementations of both algorithms. It also compares the two algorithms and lists their time complexities and differences. References are provided at the end.

Uploaded by

hfor57148
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views

Data Structure Using C (2) New Done

The document discusses selection sort and bubble sort algorithms. It provides flowcharts and C code implementations of both algorithms. It also compares the two algorithms and lists their time complexities and differences. References are provided at the end.

Uploaded by

hfor57148
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

GOVERNMENT POLYTECHNIC, NANDED

Information Technology Department


Academic year: 2023-2024
Micro-project on

Selection Sort & Bubble Sort


Program Name: Information Technology
Program Code: IF3I
Course Name: Data structures Using C.
Course Code: 22317

Name of Students Guided By: M.M Shaikh


1. Abhira Gangadhar Powade
2. Dhanshri Suryakant Bande

1
MAHARASHTRA STATE
BOARD OF TECHNICAL EDUCATION
Certificate
This is to certify that Mr. /Ms Abhira Gangadhar Powade ,
Dhanshri Suryakant Bande. roll no. 933, 962. of third semester of
diploma in Information Technology of Institute, GOVERNMENT
POLYTECHNIC, NANDED(0020) has completed the Micro
Project satisfactorily in Subject Data structures using c (22317)
for the academic year 2023-2024 as prescribed in the curriculum.
Place: NANDED

Date: ……………………… Exam. Seat No: ………………...........

Subject Teacher Head of the Department Principal


M.M Shaikh Prof. S.N.DHOLE Dr. N. L. Janrao

2
ANEEXURE I

Title of the Micro-project:- Selection Sort & Bubble Sort

Academic Year: 2023-2024


Semester: IF3I Course: Data structures using c
Course code:22317

Co addressed by Micro Project:


A: Perform basic operation on array.
B: Apply different sorting Techniques.

Major learning outcomes achieved by students by doing the project


(a) Practical outcome:
1. Implement a c program to sort an array using Selection sort

(b) Unit outcomes in Cognitive domain:


1. Write an algorithm to sort the data using a specified sorting
algorithm.
2. Explain the working of given sorting algorithm step by step with an
example and small data ser.

(c) Outcomes in Affective domain:


1. Function as Team work.
2. make proper use of computer and Internet
3. Follow ethics.
Comments/suggestions about team work
/leadership/interpersonal communication (if any)

3
…………………………………………………………………….

ROLL.NO STUDENT NAME (D5 (D5 TOTAL OUT


COL.8) COL.9) OF 10
933 Abhira Gangadhar
Powade
962 Dhanshri Suryakant
Bande

4
CONTENT
Sr. Chapter/Title
No.
1. Introduction

2. Flow chart for selection sort and bubble


sort

3. Implementation Of Selection Sort And


Bubble Sort

4. Difference between Selection sort and


bubble sort
5. Referance

5
Selection Sort

The selection sort algorithm sorts an array by repeatedly


finding the minimum element (considering ascending
order) from the unsorted part and putting it at the beginning.

The algorithm maintains two subarrays in a given array.

• The subarray which already sorted.


• The remaining subarray was unsorted.

In every iteration of the selection sort, the minimum


element (considering ascending order) from the unsorted
subarray is picked and moved to the sorted subarray.

Flowchart of the Selection Sort and


bubble sort:

6
#bubble sort

7
#Selection Sort

8
Implementation Of Selection Sort
And Bubble Sort

Implementation of Selection Sort


Below is the implementation of the above-explained algorithm.

#include <iostream>
using namespace std;
void Selection_Sort(int arr[], int n)
{
for(int i = 0; i < n - 1; ++i)
{
int min_index = i;
for(int j = i + 1; j < n; ++j)
{
if(arr[j] < arr[min_index])
min_index = j;
}
swap(arr[i], arr[min_index]);
}
}
int main()
{
int n = 5;
int arr[5] = {2, 0, 1, 4, 3};
Selection_Sort(arr, n);
cout<<"The Sorted Array by using Selection Sort is : ";
for(int i = 0; i < n; ++i)
cout<<arr[i]<<" ";
return 0;
}

Output
The Sorted Array by using Selection Sort is : 0 1 2 3 4

9
Implementation of Bubble Sort
Below is the implementation of the above-explained algorithm.

#include <iostream>
using namespace std;
void Bubble_Sort(int arr[], int n)
{
for(int i = 1; i < n; ++i)
{
for(int j = 0; j <= (n - i - 1); ++j)
{
if(arr[j] > arr[j + 1])
swap(arr[j], arr[j + 1]);
}
}
}

int main()
{
int n = 5;
int arr[5] = {2, 0, 1, 4, 3};
Bubble_Sort(arr, n);
cout<<"The Sorted Array by using Bubble Sort is : ";
for(int i = 0; i < n; ++i)
cout<<arr[i]<<" ";
return 0;
}

Output
The Sorted Array by using Bubble Sort is : 0 1 2 3 4

10
Difference between Selection sort and bubble sort

Selection Sort Bubble Sort

1. Selection sorting is a sorting Bubble sorting is a sorting algorithm


algorithm where we select the minimum where we check two elements and swap
element from the array and put that at its them at their correct positions.
correct position.
2. Its Time complexity in the Best case Its Time complexity in the Best case is
is O(N^2) O(N)

3. Selection sort performs minimum Bubble sort performs maximum number


number of swaps to sort the array of swaps to sort the array

4. Its Time complexity in the worst Its Time complexity in Worst case is
case is O(N^2) O(N^2)

5. This sorting algorithm uses the This sorting algorithm uses exchanging
selection method method

6. It is an efficient sorting technique. It is not an efficient sorting technique.

7. Is is not a stable algorithm It is a stable algorithm

8. This method is faster This method is slower

11
References

• www.goggle.com

• https://www.geeksforgeeks.org
• Data structures using C textbook

THANK YOU

12

You might also like