Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Loading...
User Settings
close menu
Welcome to Scribd!
Upload
Read for free
FAQ and support
Language (EN)
Sign in
0 ratings
0% found this document useful (0 votes)
1 views
Bubble Sort
Uploaded by
harshit.gahlaut2005
AI-enhanced
Copyright:
© All Rights Reserved
Available Formats
Download
as TXT, PDF, TXT or read online from Scribd
Download
Save
Save bubbleSort For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Bubble Sort
Uploaded by
harshit.gahlaut2005
0 ratings
0% found this document useful (0 votes)
1 views
2 pages
AI-enhanced title
Document Information
click to expand document information
Original Title
bubbleSort
Copyright
© © All Rights Reserved
Available Formats
TXT, PDF, TXT or read online from Scribd
Share this document
Share or Embed Document
Sharing Options
Share on Facebook, opens a new window
Facebook
Share on Twitter, opens a new window
Twitter
Share on LinkedIn, opens a new window
LinkedIn
Share with Email, opens mail client
Email
Copy link
Copy link
Did you find this document useful?
0%
0% found this document useful, Mark this document as useful
0%
0% found this document not useful, Mark this document as not useful
Is this content inappropriate?
Report
Copyright:
© All Rights Reserved
Available Formats
Download
as TXT, PDF, TXT or read online from Scribd
Download now
Download as txt, pdf, or txt
Save
Save bubbleSort For Later
0 ratings
0% found this document useful (0 votes)
1 views
2 pages
Bubble Sort
Uploaded by
harshit.gahlaut2005
AI-enhanced title
Copyright:
© All Rights Reserved
Available Formats
Download
as TXT, PDF, TXT or read online from Scribd
Save
Save bubbleSort For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download as txt, pdf, or txt
Jump to Page
You are on page 1
of 2
Search inside document
#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
Document
1 page
Insertion Sort
harshit.gahlaut2005
No ratings yet
Quick Sort
Document
1 page
Quick Sort
harshit.gahlaut2005
No ratings yet
SORTING
Document
11 pages
SORTING
rakesh.yadav10111966
No ratings yet
Afrizal David Maulana_231011403456
Document
4 pages
Afrizal David Maulana_231011403456
locod1140
No ratings yet
Afrizal David Maulana
Document
4 pages
Afrizal David Maulana
locod1140
No ratings yet
Cpppranaydam
Document
34 pages
Cpppranaydam
Isha D
No ratings yet
dsa codes
Document
10 pages
dsa codes
bezawadayashwitha
No ratings yet
Selection Sort
Document
1 page
Selection Sort
harshit.gahlaut2005
No ratings yet
DSA Programs
Document
16 pages
DSA Programs
muskan11825
No ratings yet
DS Lab 3
Document
6 pages
DS Lab 3
Evil Sight
No ratings yet
dsa
Document
25 pages
dsa
rohitkoslia509
No ratings yet
Merging of Two Array
Document
12 pages
Merging of Two Array
Vineet Rajput
No ratings yet
codes
Document
50 pages
codes
bezawadayashwitha
No ratings yet
#Include Using Namespace Void Int
Document
3 pages
#Include Using Namespace Void Int
aasifaftab
No ratings yet
DSA Lab5
Document
5 pages
DSA Lab5
raonetflix1999
No ratings yet
Record File - 15jULY
Document
3 pages
Record File - 15jULY
apashyamkirikiri1432
No ratings yet
Sorting
Document
8 pages
Sorting
Renganathan ramesh
No ratings yet
A1 Lab#1 22F-7465
Document
6 pages
A1 Lab#1 22F-7465
Hashir Khan
No ratings yet
DSA - Lab: Submitted To: Mam Rabia Arshad SUBMITTED BY: Muhammad Bilal
Document
18 pages
DSA - Lab: Submitted To: Mam Rabia Arshad SUBMITTED BY: Muhammad Bilal
Bilal Alone
No ratings yet
Assignment 3 (2) 24ceb0b14
Document
20 pages
Assignment 3 (2) 24ceb0b14
sv24csb1a58
No ratings yet
Vs Code by Me
Document
3 pages
Vs Code by Me
swagbucks10001
No ratings yet
Assignmwnt
Document
7 pages
Assignmwnt
pakistanhello51
No ratings yet
Bubble Sort
Document
20 pages
Bubble Sort
Yo boi Jogindar
No ratings yet
Lab No 2
Document
5 pages
Lab No 2
atiq.rehman1105
No ratings yet
Bubble Sort : Copied
Document
6 pages
Bubble Sort : Copied
Malik Ghulam Hur
No ratings yet
Bubble
Document
22 pages
Bubble
Sehar Rizwan
No ratings yet
Exp-2 (B) Priyanshu Singhal
Document
2 pages
Exp-2 (B) Priyanshu Singhal
Priyanshu Singhal
No ratings yet
#Include
Document
6 pages
#Include
suman k m
No ratings yet
Q3
Document
5 pages
Q3
upwork.workspace
No ratings yet
15315
Document
41 pages
15315
Aman Kashniyal
No ratings yet
Kamal Rohilla 2K18/CO/166 ADA Assignment 13 Apr. 2020
Document
10 pages
Kamal Rohilla 2K18/CO/166 ADA Assignment 13 Apr. 2020
kamal
No ratings yet
ADA Assignment PDF
Document
10 pages
ADA Assignment PDF
2K18/CO/166 KAMAL ROHILLA
No ratings yet
Code
Document
18 pages
Code
kisam78442
No ratings yet
dsa2
Document
30 pages
dsa2
anshulvashisht88
No ratings yet
Data Structure Nandini
Document
29 pages
Data Structure Nandini
sania khan 11 c pcm
No ratings yet
C++ Practical Program
Document
9 pages
C++ Practical Program
Raj Chauhan
No ratings yet
Aass Lab
Document
6 pages
Aass Lab
Magarsa Bedasa
No ratings yet
Need To Know Algoritims
Document
4 pages
Need To Know Algoritims
nishchay naran
No ratings yet
ADA Lab Abhi
Document
23 pages
ADA Lab Abhi
nandinitiwari1985
No ratings yet
OOCP TASK-6
Document
18 pages
OOCP TASK-6
Dhwani Yadav
No ratings yet
Knapsack
Document
1 page
Knapsack
harshit.gahlaut2005
No ratings yet
Data Structure Assignment
Document
12 pages
Data Structure Assignment
Ahmad Sultan
No ratings yet
PRIYAM NANDI - 22102088 Assignment 5
Document
10 pages
PRIYAM NANDI - 22102088 Assignment 5
priyamnandi900
No ratings yet
432 - Pract1-3 - Div A
Document
25 pages
432 - Pract1-3 - Div A
Kajal Goud
No ratings yet
Dsa Assignment
Document
2 pages
Dsa Assignment
Yashal Ijaz
No ratings yet
DSA Lab Task 3
Document
6 pages
DSA Lab Task 3
Abdul Rehman Abid
No ratings yet
Aoa Lab
Document
7 pages
Aoa Lab
anshumanasr02
No ratings yet
Bubble Sort
Document
2 pages
Bubble Sort
rohitk93639
No ratings yet
#Include #Include Using Namespace Void Int Int Void Int Int Void Int Int Int Int Char Int Int
Document
3 pages
#Include #Include Using Namespace Void Int Int Void Int Int Void Int Int Int Int Char Int Int
frgfdssd
No ratings yet
Lab Manual: Riphah International University
Document
40 pages
Lab Manual: Riphah International University
Moon Mughal
No ratings yet
Analysis Algo
Document
41 pages
Analysis Algo
Sweekriti Singh
No ratings yet
Deep Discription of Classes and Inheritance
Document
7 pages
Deep Discription of Classes and Inheritance
f228802
No ratings yet
DSA POST LAB REPORT
Document
8 pages
DSA POST LAB REPORT
ahtisham0100
No ratings yet
ADA Practical File
Document
5 pages
ADA Practical File
Soumyadeep Manna
No ratings yet
Lab Repoet#05cpp
Document
1 page
Lab Repoet#05cpp
skbhatti003
No ratings yet
Write An Algorithm and C++ Implementation For The Following: A) Insertion Sort Ans: Algorithm
Document
4 pages
Write An Algorithm and C++ Implementation For The Following: A) Insertion Sort Ans: Algorithm
Nishan Hamal
No ratings yet
Final File Dsa
Document
11 pages
Final File Dsa
Nishita Karda
No ratings yet
DAA-2
Document
6 pages
DAA-2
shivadubey2002
No ratings yet
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
Knapsack
Document
1 page
Knapsack
harshit.gahlaut2005
No ratings yet
Bubble Sort
Document
1 page
Bubble Sort
harshit.gahlaut2005
No ratings yet
Selection Sort
Document
1 page
Selection Sort
harshit.gahlaut2005
No ratings yet
Heap Sort
Document
1 page
Heap Sort
harshit.gahlaut2005
No ratings yet