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)
4 views
2 pages
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
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)
4 views
2 pages
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
Carousel Previous
Carousel Next
Download
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
OOP Pr-1
PDF
No ratings yet
OOP Pr-1
3 pages
Dsa Codes
PDF
No ratings yet
Dsa Codes
10 pages
DAA PF SIMRA 48 Final
PDF
No ratings yet
DAA PF SIMRA 48 Final
29 pages
Algo
PDF
No ratings yet
Algo
13 pages
Sorting Lab Exercise
PDF
No ratings yet
Sorting Lab Exercise
9 pages
Algorithm Sorting
PDF
No ratings yet
Algorithm Sorting
16 pages
Exp 03 Ds Atharva
PDF
No ratings yet
Exp 03 Ds Atharva
11 pages
Dsa Post Lab Report
PDF
No ratings yet
Dsa Post Lab Report
8 pages
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
Code
PDF
No ratings yet
Code
18 pages
Daa 2
PDF
No ratings yet
Daa 2
6 pages
T3 - Searching Sorting
PDF
No ratings yet
T3 - Searching Sorting
20 pages
Record File - 15jULY
PDF
No ratings yet
Record File - 15jULY
3 pages
Sorting
PDF
No ratings yet
Sorting
7 pages
Q3
PDF
No ratings yet
Q3
5 pages
SORTING
PDF
No ratings yet
SORTING
11 pages
Chap 2 Lab Exercise
PDF
No ratings yet
Chap 2 Lab Exercise
5 pages
Lab Manual Dsa
PDF
No ratings yet
Lab Manual Dsa
18 pages
Lab 4
PDF
No ratings yet
Lab 4
6 pages
Programming
PDF
No ratings yet
Programming
8 pages
DAA File
PDF
No ratings yet
DAA File
7 pages
Algorithom Lab 5 Sawon
PDF
No ratings yet
Algorithom Lab 5 Sawon
8 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
Bubble Sort
PDF
No ratings yet
Bubble Sort
2 pages
DATA STRUCTURE - Lab - Manual Final
PDF
No ratings yet
DATA STRUCTURE - Lab - Manual Final
35 pages
Insertion Sort
PDF
No ratings yet
Insertion Sort
1 page
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
Chirag ADA fILE
PDF
No ratings yet
Chirag ADA fILE
22 pages
Practical Number 6
PDF
No ratings yet
Practical Number 6
2 pages
Ex 6 Sort
PDF
No ratings yet
Ex 6 Sort
14 pages
DS Lab 3
PDF
No ratings yet
DS Lab 3
6 pages
PRGM 8,9
PDF
No ratings yet
PRGM 8,9
1 page
Vs Code by Me
PDF
No ratings yet
Vs Code by Me
3 pages
Bubble
PDF
No ratings yet
Bubble
22 pages
Exp 03 DS Jaid
PDF
No ratings yet
Exp 03 DS Jaid
11 pages
Quick Sort
PDF
No ratings yet
Quick Sort
1 page
Tayyab Khan DSA Lab Report 1
PDF
No ratings yet
Tayyab Khan DSA Lab Report 1
13 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
Selection Sort
PDF
No ratings yet
Selection Sort
1 page
Oop Assignmnet 1
PDF
No ratings yet
Oop Assignmnet 1
12 pages
432 - Pract1-3 - Div A
PDF
No ratings yet
432 - Pract1-3 - Div A
25 pages
Dsa Assignment
PDF
No ratings yet
Dsa Assignment
2 pages
Code For Selection Sort
PDF
No ratings yet
Code For Selection Sort
5 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
20BCS057 - Bilal Sajid - P2
PDF
No ratings yet
20BCS057 - Bilal Sajid - P2
7 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
SC22B135
PDF
No ratings yet
SC22B135
1 page
Bubble Sort : Copied
PDF
No ratings yet
Bubble Sort : Copied
6 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
Sorting Using Templates
PDF
No ratings yet
Sorting Using Templates
5 pages
Bubble Sort: Output
PDF
No ratings yet
Bubble Sort: Output
4 pages
Bubble Sorting
PDF
No ratings yet
Bubble Sorting
3 pages
#Include #Include: / C++ Program - Bubble Sort
PDF
No ratings yet
#Include #Include: / C++ Program - Bubble Sort
1 page
Exp-2 (B) Priyanshu Singhal
PDF
No ratings yet
Exp-2 (B) Priyanshu Singhal
2 pages
Exp No: 6B Bubble Sort Date: AIM
PDF
No ratings yet
Exp No: 6B Bubble Sort Date: AIM
2 pages
C++ Functions and tutorial
From Everand
C++ Functions and tutorial
Nino Paiotta
No ratings yet
Computer Engineering Laboratory Solution Primer
From Everand
Computer Engineering Laboratory Solution Primer
Karan Bhandari
No ratings yet
150+ C Pattern Programs
From Everand
150+ C Pattern Programs
Hernando Abella
No ratings yet