SlideShare a Scribd company logo
1 of 13
PRESENTATION
On
Bubble sorting
Submitted to-
Ms. Apurva Gautam
Dept. of Computer Science
Submitted By-
Ayush Pandey
B.C.A. II sem.
WELCOME
Contents
● Introduction to Sorting
● Introduction to Bubble Sort
● Example of Bubble Sort
● Algorithm of Bubble sort
● Program of Bubble sort
Introduction
Sorting- Sorting takes an unordered
collection and makes it an ordered one.
1 2 3 4 5
1 2 3 4 5
5 7 2 1 4
1 2 4 5 7
Introduction
Bubble sort- The Algorithm is Bubble Sort
involves two steps over and over until the
data sorted.
1 Compare Adjacent two element if
necessary swap them.
Algorithm of Bubble Sort
1.Initialisation
Set I=0
2. repeat step 3 to 5 until I<M
3. J=0
4.repeat step 5 until J < N – I -1
5. If A[J] > A[J+1] then
step temp=A[J]
Set A[J]=A[J+1]
set A[J+1]= temp
end if
6. exit
Example
5 7 2 1 4
5 2 7 1 4
1 2 3 4 5
5 2 1 7 45 2 1 7 4
5 2 1 4 7
2
2 5 1 4 72
2 1 5 4 7
Example
● 3
2 5 4 71
1 2 4 5 7
Program of Bubble Sort
#include<stdio.h>
#include<conio.h>
void main()
{int arr[20],i,j,k,n;
printf(“Enter the size of array”);
scanf(“%d”,&n);
printf(“Enter the element of array”);
for(i=0;i<n;i++)
{scanf(“%d”,&arr[i]):
}
for(i=0;I<n;ioi++)
{for(j=i+1;j<n;j++)
{if(arr[i]>arr[j])
●
{
arr[i]=k;
arr[i]=arr[j];
arr[j]=k;
}}}
printf(“New array is”);
●
Print
●
getch();
●
}
THANK YOU

More Related Content

What's hot (9)

Concurrent force system
Concurrent force systemConcurrent force system
Concurrent force system
 
201707 CSE110 Lecture 29
201707 CSE110 Lecture 29201707 CSE110 Lecture 29
201707 CSE110 Lecture 29
 
Integration by parts
Integration by partsIntegration by parts
Integration by parts
 
Factor Label
Factor LabelFactor Label
Factor Label
 
Approximation Algorithms Part Two: More Constant factor approximations
Approximation Algorithms Part Two: More Constant factor approximationsApproximation Algorithms Part Two: More Constant factor approximations
Approximation Algorithms Part Two: More Constant factor approximations
 
Presentation_Parallel GRASP algorithm for job shop scheduling
Presentation_Parallel GRASP algorithm for job shop schedulingPresentation_Parallel GRASP algorithm for job shop scheduling
Presentation_Parallel GRASP algorithm for job shop scheduling
 
algorithms
algorithmsalgorithms
algorithms
 
Determininstic rounding of linear programs
Determininstic rounding of linear programsDetermininstic rounding of linear programs
Determininstic rounding of linear programs
 
Python Programming | JNTUA | UNIT 3 | Updating Variables & Iteration |
Python Programming | JNTUA | UNIT 3 | Updating Variables & Iteration | Python Programming | JNTUA | UNIT 3 | Updating Variables & Iteration |
Python Programming | JNTUA | UNIT 3 | Updating Variables & Iteration |
 

Recently uploaded

electrical installation and maintenance.
electrical installation and maintenance.electrical installation and maintenance.
electrical installation and maintenance.
benjamincojr
 
Performance enhancement of machine learning algorithm for breast cancer diagn...
Performance enhancement of machine learning algorithm for breast cancer diagn...Performance enhancement of machine learning algorithm for breast cancer diagn...
Performance enhancement of machine learning algorithm for breast cancer diagn...
IJECEIAES
 
Seizure stage detection of epileptic seizure using convolutional neural networks
Seizure stage detection of epileptic seizure using convolutional neural networksSeizure stage detection of epileptic seizure using convolutional neural networks
Seizure stage detection of epileptic seizure using convolutional neural networks
IJECEIAES
 
Maher Othman Interior Design Portfolio..
Maher Othman Interior Design Portfolio..Maher Othman Interior Design Portfolio..
Maher Othman Interior Design Portfolio..
MaherOthman7
 
Online crime reporting system project.pdf
Online crime reporting system project.pdfOnline crime reporting system project.pdf
Online crime reporting system project.pdf
Kamal Acharya
 

Recently uploaded (20)

electrical installation and maintenance.
electrical installation and maintenance.electrical installation and maintenance.
electrical installation and maintenance.
 
Instruct Nirmaana 24-Smart and Lean Construction Through Technology.pdf
Instruct Nirmaana 24-Smart and Lean Construction Through Technology.pdfInstruct Nirmaana 24-Smart and Lean Construction Through Technology.pdf
Instruct Nirmaana 24-Smart and Lean Construction Through Technology.pdf
 
Artificial Intelligence in due diligence
Artificial Intelligence in due diligenceArtificial Intelligence in due diligence
Artificial Intelligence in due diligence
 
Performance enhancement of machine learning algorithm for breast cancer diagn...
Performance enhancement of machine learning algorithm for breast cancer diagn...Performance enhancement of machine learning algorithm for breast cancer diagn...
Performance enhancement of machine learning algorithm for breast cancer diagn...
 
Seizure stage detection of epileptic seizure using convolutional neural networks
Seizure stage detection of epileptic seizure using convolutional neural networksSeizure stage detection of epileptic seizure using convolutional neural networks
Seizure stage detection of epileptic seizure using convolutional neural networks
 
Seismic Hazard Assessment Software in Python by Prof. Dr. Costas Sachpazis
Seismic Hazard Assessment Software in Python by Prof. Dr. Costas SachpazisSeismic Hazard Assessment Software in Python by Prof. Dr. Costas Sachpazis
Seismic Hazard Assessment Software in Python by Prof. Dr. Costas Sachpazis
 
Passive Air Cooling System and Solar Water Heater.ppt
Passive Air Cooling System and Solar Water Heater.pptPassive Air Cooling System and Solar Water Heater.ppt
Passive Air Cooling System and Solar Water Heater.ppt
 
Research Methodolgy & Intellectual Property Rights Series 2
Research Methodolgy & Intellectual Property Rights Series 2Research Methodolgy & Intellectual Property Rights Series 2
Research Methodolgy & Intellectual Property Rights Series 2
 
Geometric constructions Engineering Drawing.pdf
Geometric constructions Engineering Drawing.pdfGeometric constructions Engineering Drawing.pdf
Geometric constructions Engineering Drawing.pdf
 
handbook on reinforce concrete and detailing
handbook on reinforce concrete and detailinghandbook on reinforce concrete and detailing
handbook on reinforce concrete and detailing
 
21scheme vtu syllabus of visveraya technological university
21scheme vtu syllabus of visveraya technological university21scheme vtu syllabus of visveraya technological university
21scheme vtu syllabus of visveraya technological university
 
SLIDESHARE PPT-DECISION MAKING METHODS.pptx
SLIDESHARE PPT-DECISION MAKING METHODS.pptxSLIDESHARE PPT-DECISION MAKING METHODS.pptx
SLIDESHARE PPT-DECISION MAKING METHODS.pptx
 
Introduction to Artificial Intelligence and History of AI
Introduction to Artificial Intelligence and History of AIIntroduction to Artificial Intelligence and History of AI
Introduction to Artificial Intelligence and History of AI
 
Maher Othman Interior Design Portfolio..
Maher Othman Interior Design Portfolio..Maher Othman Interior Design Portfolio..
Maher Othman Interior Design Portfolio..
 
Online crime reporting system project.pdf
Online crime reporting system project.pdfOnline crime reporting system project.pdf
Online crime reporting system project.pdf
 
Research Methodolgy & Intellectual Property Rights Series 1
Research Methodolgy & Intellectual Property Rights Series 1Research Methodolgy & Intellectual Property Rights Series 1
Research Methodolgy & Intellectual Property Rights Series 1
 
CLOUD COMPUTING SERVICES - Cloud Reference Modal
CLOUD COMPUTING SERVICES - Cloud Reference ModalCLOUD COMPUTING SERVICES - Cloud Reference Modal
CLOUD COMPUTING SERVICES - Cloud Reference Modal
 
"United Nations Park" Site Visit Report.
"United Nations Park" Site  Visit Report."United Nations Park" Site  Visit Report.
"United Nations Park" Site Visit Report.
 
Linux Systems Programming: Semaphores, Shared Memory, and Message Queues
Linux Systems Programming: Semaphores, Shared Memory, and Message QueuesLinux Systems Programming: Semaphores, Shared Memory, and Message Queues
Linux Systems Programming: Semaphores, Shared Memory, and Message Queues
 
Worksharing and 3D Modeling with Revit.pptx
Worksharing and 3D Modeling with Revit.pptxWorksharing and 3D Modeling with Revit.pptx
Worksharing and 3D Modeling with Revit.pptx
 

Bubble sort

  • 1. PRESENTATION On Bubble sorting Submitted to- Ms. Apurva Gautam Dept. of Computer Science Submitted By- Ayush Pandey B.C.A. II sem.
  • 3. Contents ● Introduction to Sorting ● Introduction to Bubble Sort ● Example of Bubble Sort ● Algorithm of Bubble sort ● Program of Bubble sort
  • 4. Introduction Sorting- Sorting takes an unordered collection and makes it an ordered one. 1 2 3 4 5 1 2 3 4 5 5 7 2 1 4 1 2 4 5 7
  • 5. Introduction Bubble sort- The Algorithm is Bubble Sort involves two steps over and over until the data sorted. 1 Compare Adjacent two element if necessary swap them.
  • 6. Algorithm of Bubble Sort 1.Initialisation Set I=0 2. repeat step 3 to 5 until I<M 3. J=0 4.repeat step 5 until J < N – I -1 5. If A[J] > A[J+1] then step temp=A[J]
  • 7. Set A[J]=A[J+1] set A[J+1]= temp end if 6. exit
  • 8. Example 5 7 2 1 4 5 2 7 1 4 1 2 3 4 5
  • 9. 5 2 1 7 45 2 1 7 4 5 2 1 4 7
  • 10. 2 2 5 1 4 72 2 1 5 4 7
  • 11. Example ● 3 2 5 4 71 1 2 4 5 7
  • 12. Program of Bubble Sort #include<stdio.h> #include<conio.h> void main() {int arr[20],i,j,k,n; printf(“Enter the size of array”); scanf(“%d”,&n); printf(“Enter the element of array”); for(i=0;i<n;i++) {scanf(“%d”,&arr[i]): } for(i=0;I<n;ioi++) {for(j=i+1;j<n;j++) {if(arr[i]>arr[j]) ● { arr[i]=k; arr[i]=arr[j]; arr[j]=k; }}} printf(“New array is”); ● Print ● getch(); ● }