Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
2 views
Bubble Sort
Uploaded by
harshit.gahlaut2005
AI-enhanced title
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
Download now
Download
Save bubbleSort For Later
Download
Save
Save bubbleSort For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
2 views
Bubble Sort
Uploaded by
harshit.gahlaut2005
AI-enhanced title
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
Download now
Download
Save bubbleSort For Later
Carousel Previous
Carousel Next
Save
Save bubbleSort For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 2
Search
Fullscreen
#include <iostream>
using namespace std;
void bubblesort(int arr[], int n)
{
int temp;
for (int i = 0; i < n - 1; i++)
{
for (int j = n - 1; j > i; j--)
{
if (arr[j] < arr[j - 1])
{
temp = arr[j];
arr[j] = arr[j - 1];
arr[j - 1] = temp;
}
}
}
}
int main()
{
int arr[40];
int n;
cout << "Enter the no of elements in array" << endl;
cin >> n;
cout << "Enter the elements" << endl;
for (int j = 0; j < n; j++)
cin >> arr[j];
bubblesort(arr, n);
cout << "Sorted Array" << endl;
for (int i = 0; i < n; i++)
cout << arr[i] << " ";
return 0;
}
#include <iostream>
using namespace std;
void insertion_sort(int A[], int n)
{
int key, j;
for (int i = 1; i < n; i++)
{
key = A[i];
j = i - 1;
while (j >= 0 && A[j] > key)
{
A[j+1] = A[j];
j--;
}
A[j + 1] = key;
}
}
int main()
{
int num;
int arr[20];
cout << "Enter the number of elements in the array : ";
cin >> num;
for (int i = 0; i < num; i++)
{
cout << "Enter the element of the array : ";
cin >> arr[i];
}
cout << "Unsorted Array :" << endl;
for (int i = 0; i < num; i++)
cout << arr[i] << " ";
cout << endl;
insertion_sort(arr, num);
cout << "Sorted Array :" << endl;
for (int i = 0; i < num; i++)
cout << arr[i] << " ";
return 0;
}
You might also like
Insertion Sort
PDF
No ratings yet
Insertion Sort
1 page
dsa codes
PDF
No ratings yet
dsa codes
10 pages
Record File - 15jULY
PDF
No ratings yet
Record File - 15jULY
3 pages
20BCS057 - Bilal Sajid - P2
PDF
No ratings yet
20BCS057 - Bilal Sajid - P2
7 pages
Bubble Sort
PDF
No ratings yet
Bubble Sort
2 pages
Prepared by Dr/Kadry Ali 1 Method: #Include Using Namespace: STD
PDF
No ratings yet
Prepared by Dr/Kadry Ali 1 Method: #Include Using Namespace: STD
4 pages
sorting lab exercise
PDF
No ratings yet
sorting lab exercise
9 pages
Q7) Write A C++ Program Using Types of Sorting.: 1. Bubble Sort 2. Insertion Sort
PDF
No ratings yet
Q7) Write A C++ Program Using Types of Sorting.: 1. Bubble Sort 2. Insertion Sort
19 pages
SC22B135(1)
PDF
No ratings yet
SC22B135(1)
1 page
Q3
PDF
No ratings yet
Q3
5 pages
Vs Code by Me
PDF
No ratings yet
Vs Code by Me
3 pages
Exp-2 (B) Priyanshu Singhal
PDF
No ratings yet
Exp-2 (B) Priyanshu Singhal
2 pages
Tayyab Khan DSA Lab Report 1
PDF
No ratings yet
Tayyab Khan DSA Lab Report 1
13 pages
DATA STRUCTURE - Lab - Manual Final
PDF
No ratings yet
DATA STRUCTURE - Lab - Manual Final
35 pages
Name: Arsalna Saif Roll No: 45 Department: Cs &it Class: Bsit (3nd Semester) Assignment Of: Data Structure Lab Assignment To: Ms Rabia
PDF
No ratings yet
Name: Arsalna Saif Roll No: 45 Department: Cs &it Class: Bsit (3nd Semester) Assignment Of: Data Structure Lab Assignment To: Ms Rabia
7 pages
432 - Pract1-3 - Div A
PDF
No ratings yet
432 - Pract1-3 - Div A
25 pages
Algorithm Sorting
PDF
No ratings yet
Algorithm Sorting
16 pages
Programming
PDF
No ratings yet
Programming
8 pages
SORTING
PDF
No ratings yet
SORTING
11 pages
Dsa Assignment
PDF
No ratings yet
Dsa Assignment
2 pages
Bubble Sort : Copied
PDF
No ratings yet
Bubble Sort : Copied
6 pages
Ex 6 Sort
PDF
No ratings yet
Ex 6 Sort
14 pages
#Include #Include: / C++ Program - Bubble Sort
PDF
No ratings yet
#Include #Include: / C++ Program - Bubble Sort
1 page
Lab 11
PDF
No ratings yet
Lab 11
10 pages
DAA-2
PDF
No ratings yet
DAA-2
6 pages
Wap For Sorting A List of Numbers and Names Using Insertion, Selection, Quick and Merge Sorting Techniques
PDF
No ratings yet
Wap For Sorting A List of Numbers and Names Using Insertion, Selection, Quick and Merge Sorting Techniques
2 pages
T3 - Searching Sorting
PDF
No ratings yet
T3 - Searching Sorting
20 pages
Practical Number 6
PDF
No ratings yet
Practical Number 6
2 pages
DS Lab 3
PDF
No ratings yet
DS Lab 3
6 pages
Mulatie Data Structure
PDF
No ratings yet
Mulatie Data Structure
4 pages
Quick Sort
PDF
No ratings yet
Quick Sort
1 page
DSA POST LAB REPORT
PDF
No ratings yet
DSA POST LAB REPORT
8 pages
Exp No: 6B Bubble Sort Date: AIM
PDF
No ratings yet
Exp No: 6B Bubble Sort Date: AIM
2 pages
OOP Pr-1
PDF
No ratings yet
OOP Pr-1
3 pages
Sorting Using Templates
PDF
No ratings yet
Sorting Using Templates
5 pages
Selection Sort
PDF
No ratings yet
Selection Sort
1 page
DAA PF SIMRA 48 Final
PDF
No ratings yet
DAA PF SIMRA 48 Final
29 pages
Selection Sort: "/N - SELECTION SORT - /N/N" "Enter No. of Elements "
PDF
No ratings yet
Selection Sort: "/N - SELECTION SORT - /N/N" "Enter No. of Elements "
10 pages
Bubble Sort: Output
PDF
No ratings yet
Bubble Sort: Output
4 pages
Code For Selection Sort
PDF
No ratings yet
Code For Selection Sort
5 pages
Code
PDF
No ratings yet
Code
18 pages
Bubble
PDF
No ratings yet
Bubble
22 pages
Algorithom Lab 5 Sawon
PDF
No ratings yet
Algorithom Lab 5 Sawon
8 pages
Algo
PDF
No ratings yet
Algo
13 pages
program To Show Binary Search
PDF
No ratings yet
program To Show Binary Search
17 pages
Program 1: Write A Programto Implement Bubble Sort. Source Code
PDF
No ratings yet
Program 1: Write A Programto Implement Bubble Sort. Source Code
9 pages
Data Structure
PDF
No ratings yet
Data Structure
4 pages
Chap 2 Lab Exercise
PDF
No ratings yet
Chap 2 Lab Exercise
5 pages
prgm8,9
PDF
No ratings yet
prgm8,9
1 page
Ahsan Naseer Lab Report 5
PDF
No ratings yet
Ahsan Naseer Lab Report 5
17 pages
DSA LAB 104
PDF
No ratings yet
DSA LAB 104
6 pages
Bubble Sorting
PDF
No ratings yet
Bubble Sorting
3 pages
Oop Assignmnet 1
PDF
No ratings yet
Oop Assignmnet 1
12 pages
DAA Lab1
PDF
No ratings yet
DAA Lab1
3 pages
Dsa Assign 9
PDF
No ratings yet
Dsa Assign 9
3 pages
Aoa Lab
PDF
No ratings yet
Aoa Lab
7 pages
Algorithm Assignment
PDF
No ratings yet
Algorithm Assignment
2 pages
150+ C Pattern Programs
From Everand
150+ C Pattern Programs
Hernando Abella
No ratings yet
Computer Engineering Laboratory Solution Primer
From Everand
Computer Engineering Laboratory Solution Primer
Karan Bhandari
No ratings yet
C++ Functions and tutorial
From Everand
C++ Functions and tutorial
Nino Paiotta
No ratings yet