SlideShare a Scribd company logo
1 of 82
• A Presentation topic for c++ topic
• A Good style and appreciated
Sorting
 Sorting takes an unordered collection and
makes it an ordered one.
512354277 101
1 2 3 4 5 6
5 12 35 42 77 101
1 2 3 4 5 6
Introduction: Bubble Sort
Also called Exchange sort.
It repeatedly visits the array and compares two items at a
time. It swaps these two items if they are in the wrong order.
It continues to visit the array until no swaps are needed that
means the array is sorted.
674523 14 6 3398 42
The First “Bubble Up”
674523 14 6 3398 42
The First “Bubble Up”
674523 14 6 3398 42
Swap
The First “Bubble Up”
674598 14 6 3323 42
Swap
The First “Bubble Up”
674598 14 6 3323 42
The First “Bubble Up”
674598 14 6 3323 42
Swap
The First “Bubble Up”
679845 14 6 3323 42
Swap
The First “Bubble Up”
679845 14 6 3323 42
The First “Bubble Up”
679845 14 6 3323 42
Swap
The First “Bubble Up”
671445 98 6 3323 42
Swap
The First “Bubble Up”
671445 98 6 3323 42
The First “Bubble Up”
671445 98 6 3323 42
Swap
The First “Bubble Up”
671445 6 98 3323 42
Swap
The First “Bubble Up”
671445 6 98 3323 42
The First “Bubble Up”
671445 6 98 3323 42
Swap
The First “Bubble Up”
981445 6 67 3323 42
Swap
The First “Bubble Up”
981445 6 67 3323 42
The First “Bubble Up”
981445 6 67 3323 42
Swap
The First “Bubble Up”
331445 6 67 9823 42
Swap
The First “Bubble Up”
331445 6 67 9823 42
The First “Bubble Up”
331445 6 67 9823 42
Swap
The First “Bubble Up”
331445 6 67 4223 98
Swap
The First “Bubble Up”
331445 6 67 4223 98
Finished first “Bubble Up”
The First “Bubble Up”
The Second “Bubble Up”
331445 6 67 4223 98
The Second “Bubble Up”
331445 6 67 4223 98
No Swap
The Second “Bubble Up”
331445 6 67 4223 98
The Second “Bubble Up”
331445 6 67 4223 98
Swap
The Second “Bubble Up”
334514 6 67 4223 98
Swap
The Second “Bubble Up”
334514 6 67 4223 98
The Second “Bubble Up”
334514 6 67 4223 98
Swap
The Second “Bubble Up”
33614 45 67 4223 98
Swap
The Second “Bubble Up”
33614 45 67 4223 98
The Second “Bubble Up”
33614 45 67 4223 98
No Swap
The Second “Bubble Up”
33614 45 67 4223 98
The Second “Bubble Up”
33614 45 67 4223 98
Swap
The Second “Bubble Up”
67614 45 33 4223 98
Swap
The Second “Bubble Up”
67614 45 33 4223 98
The Second “Bubble Up”
67614 45 33 4223 98
Swap
The Second “Bubble Up”
42614 45 33 6723 98
Swap
42614 45 33 6723 98
Finished second “Bubble Up”
The Second “Bubble Up”
The Third “Bubble Up”
42614 45 33 6723 98
The Third “Bubble Up”
42614 45 33 6723 98
Swap
The Third “Bubble Up”
42623 45 33 6714 98
Swap
The Third “Bubble Up”
42623 45 33 6714 98
The Third “Bubble Up”
42623 45 33 6714 98
Swap
The Third “Bubble Up”
42236 45 33 6714 98
Swap
The Third “Bubble Up”
42236 45 33 6714 98
The Third “Bubble Up”
42236 45 33 6714 98
No Swap
The Third “Bubble Up”
42236 45 33 6714 98
The Third “Bubble Up”
42236 45 33 6714 98
Swap
The Third “Bubble Up”
42236 33 45 6714 98
Swap
The Third “Bubble Up”
42236 33 45 6714 98
The Third “Bubble Up”
42236 33 45 6714 98
Swap
The Third “Bubble Up”
45236 33 42 6714 98
Swap
After Third Pass of Outer Loop
45236 33 42 6714 98
Finished third “Bubble Up”
The Fourth “Bubble Up”
45236 33 42 6714 98
The Fourth “Bubble Up”
45236 33 42 6714 98
Swap
The Fourth “Bubble Up”
452314 33 42 676 98
Swap
The Fourth “Bubble Up”
452314 33 42 676 98
The Fourth “Bubble Up”
452314 33 42 676 98
No Swap
The Fourth “Bubble Up”
452314 33 42 676 98
The Fourth “Bubble Up”
452314 33 42 676 98
No Swap
The Fourth “Bubble Up”
452314 33 42 676 98
The Fourth “Bubble Up”
452314 33 42 676 98
No Swap
452314 33 42 676 98
Finished fourth “Bubble Up”
After Fourth Pass of Outer Loop
The Fifth “Bubble Up”
452314 33 42 676 98
The Fifth “Bubble Up”
452314 33 42 676 98
No Swap
The Fifth “Bubble Up”
452314 33 42 676 98
The Fifth “Bubble Up”
452314 33 42 676 98
No Swap
The Fifth “Bubble Up”
452314 33 42 676 98
The Fifth “Bubble Up”
452314 33 42 676 98
No Swap
After Fifth Pass of Outer Loop
452314 33 42 676 98
Finished fifth “Bubble Up”
452314 33 42 676 98
We did not do any swapping,
so all of the other elements
must be correctly placed.
We can “skip” the last two
passes of the outer loop.
Program
void main()
{
int arr[5],i,j,tem;
cout<<“Enter Five Values”;
for(i=0,i<5,i++)
cin>>arr[i];
cout<<“The origanal values in array:n”;
for(i=0;i<5;i++)
cout<<arr[i]<<“ “;
for(i=0;i<5;i++)
for(j=0;j<4;j++)
If(arr[ j ]>arr[ j+1 ]
{
tem=arr[ j ];
arr[ j ]=arr[ j+1 ];
arr[ j+1]=tem;
}
cout<<“n The sorted array: n”;
for(i=0;i<5;i++)
cout<<arr[ i ]<<“ “;
getch();
}

More Related Content

What's hot

What's hot (20)

Data Structures - Lecture 8 [Sorting Algorithms]
Data Structures - Lecture 8 [Sorting Algorithms]Data Structures - Lecture 8 [Sorting Algorithms]
Data Structures - Lecture 8 [Sorting Algorithms]
 
Shell sort
Shell sortShell sort
Shell sort
 
Abstract data types
Abstract data typesAbstract data types
Abstract data types
 
Sorting algorithms
Sorting algorithmsSorting algorithms
Sorting algorithms
 
Circular queue
Circular queueCircular queue
Circular queue
 
Linked List
Linked ListLinked List
Linked List
 
Presentation on the topic selection sort
Presentation on the topic selection sortPresentation on the topic selection sort
Presentation on the topic selection sort
 
Queue data structure
Queue data structureQueue data structure
Queue data structure
 
Queue
QueueQueue
Queue
 
Sorting Algorithms
Sorting AlgorithmsSorting Algorithms
Sorting Algorithms
 
Sorting Algorithms
Sorting AlgorithmsSorting Algorithms
Sorting Algorithms
 
Bubble sort
Bubble sortBubble sort
Bubble sort
 
Searching and Sorting Techniques in Data Structure
Searching and Sorting Techniques in Data StructureSearching and Sorting Techniques in Data Structure
Searching and Sorting Techniques in Data Structure
 
DOUBLE LINKED LIST(DATA STRUCTURE) PPT BY PRASUN KUMAR
DOUBLE LINKED LIST(DATA STRUCTURE) PPT BY PRASUN KUMARDOUBLE LINKED LIST(DATA STRUCTURE) PPT BY PRASUN KUMAR
DOUBLE LINKED LIST(DATA STRUCTURE) PPT BY PRASUN KUMAR
 
Pseudocode By ZAK
Pseudocode By ZAKPseudocode By ZAK
Pseudocode By ZAK
 
Insertion sort
Insertion sortInsertion sort
Insertion sort
 
Polynomial reppresentation using Linkedlist-Application of LL.pptx
Polynomial reppresentation using Linkedlist-Application of LL.pptxPolynomial reppresentation using Linkedlist-Application of LL.pptx
Polynomial reppresentation using Linkedlist-Application of LL.pptx
 
Quick sort
Quick sortQuick sort
Quick sort
 
Insertion Sort Algorithm
Insertion Sort AlgorithmInsertion Sort Algorithm
Insertion Sort Algorithm
 
Binary Tree Traversal
Binary Tree TraversalBinary Tree Traversal
Binary Tree Traversal
 

Viewers also liked (19)

Bubble sort
Bubble sort Bubble sort
Bubble sort
 
Selection sort
Selection sortSelection sort
Selection sort
 
Sorting
SortingSorting
Sorting
 
Sorting Algorithms
Sorting AlgorithmsSorting Algorithms
Sorting Algorithms
 
Selection sort
Selection sortSelection sort
Selection sort
 
Data Structures - Searching & sorting
Data Structures - Searching & sortingData Structures - Searching & sorting
Data Structures - Searching & sorting
 
Sorting
SortingSorting
Sorting
 
Bubble sort
Bubble sortBubble sort
Bubble sort
 
Working of Merge Sort Code
Working of Merge Sort CodeWorking of Merge Sort Code
Working of Merge Sort Code
 
Python Day1
Python Day1Python Day1
Python Day1
 
Data Structure Sorting
Data Structure SortingData Structure Sorting
Data Structure Sorting
 
Sorting
SortingSorting
Sorting
 
8 Pointers
8 Pointers8 Pointers
8 Pointers
 
sort search in C
 sort search in C  sort search in C
sort search in C
 
Operating Systems - Intro to C++
Operating Systems - Intro to C++Operating Systems - Intro to C++
Operating Systems - Intro to C++
 
Linear and Bianry search
Linear and Bianry searchLinear and Bianry search
Linear and Bianry search
 
Algorithms
AlgorithmsAlgorithms
Algorithms
 
tecnology els virus
tecnology els virustecnology els virus
tecnology els virus
 
Investment bank
Investment bankInvestment bank
Investment bank
 

Similar to Bubble sort a best presentation topic

Sorting bubble-sort anim
Sorting   bubble-sort animSorting   bubble-sort anim
Sorting bubble-sort animFajar Zain
 
Sorting techniques Anil Dutt
Sorting techniques Anil DuttSorting techniques Anil Dutt
Sorting techniques Anil DuttAnil Dutt
 
Bubble sort/ Exchange sort Algorithmdata structures and algorithms-2018,bs it...
Bubble sort/ Exchange sort Algorithmdata structures and algorithms-2018,bs it...Bubble sort/ Exchange sort Algorithmdata structures and algorithms-2018,bs it...
Bubble sort/ Exchange sort Algorithmdata structures and algorithms-2018,bs it...Muhammad Abuzar
 
Bubble Sort Python
Bubble Sort PythonBubble Sort Python
Bubble Sort PythonValneyFilho1
 
sorting techniques PPT.ppt
sorting techniques PPT.pptsorting techniques PPT.ppt
sorting techniques PPT.pptAnilVastav
 

Similar to Bubble sort a best presentation topic (9)

Bubble sort
Bubble sortBubble sort
Bubble sort
 
Bubble sort
Bubble sortBubble sort
Bubble sort
 
Sorting bubble-sort anim
Sorting   bubble-sort animSorting   bubble-sort anim
Sorting bubble-sort anim
 
Sorting techniques Anil Dutt
Sorting techniques Anil DuttSorting techniques Anil Dutt
Sorting techniques Anil Dutt
 
Bubble sort/ Exchange sort Algorithmdata structures and algorithms-2018,bs it...
Bubble sort/ Exchange sort Algorithmdata structures and algorithms-2018,bs it...Bubble sort/ Exchange sort Algorithmdata structures and algorithms-2018,bs it...
Bubble sort/ Exchange sort Algorithmdata structures and algorithms-2018,bs it...
 
cs1311lecture16wdl.ppt
cs1311lecture16wdl.pptcs1311lecture16wdl.ppt
cs1311lecture16wdl.ppt
 
Bubble Sort Python
Bubble Sort PythonBubble Sort Python
Bubble Sort Python
 
Bubble Sort.ppt
Bubble Sort.pptBubble Sort.ppt
Bubble Sort.ppt
 
sorting techniques PPT.ppt
sorting techniques PPT.pptsorting techniques PPT.ppt
sorting techniques PPT.ppt
 

Recently uploaded

Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4JOYLYNSAMANIEGO
 
Measures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped dataMeasures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped dataBabyAnnMotar
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONHumphrey A Beña
 
TEACHER REFLECTION FORM (NEW SET........).docx
TEACHER REFLECTION FORM (NEW SET........).docxTEACHER REFLECTION FORM (NEW SET........).docx
TEACHER REFLECTION FORM (NEW SET........).docxruthvilladarez
 
Expanded definition: technical and operational
Expanded definition: technical and operationalExpanded definition: technical and operational
Expanded definition: technical and operationalssuser3e220a
 
Activity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translationActivity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translationRosabel UA
 
EMBODO Lesson Plan Grade 9 Law of Sines.docx
EMBODO Lesson Plan Grade 9 Law of Sines.docxEMBODO Lesson Plan Grade 9 Law of Sines.docx
EMBODO Lesson Plan Grade 9 Law of Sines.docxElton John Embodo
 
4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptxmary850239
 
ClimART Action | eTwinning Project
ClimART Action    |    eTwinning ProjectClimART Action    |    eTwinning Project
ClimART Action | eTwinning Projectjordimapav
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptxmary850239
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management SystemChristalin Nelson
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 
Presentation Activity 2. Unit 3 transv.pptx
Presentation Activity 2. Unit 3 transv.pptxPresentation Activity 2. Unit 3 transv.pptx
Presentation Activity 2. Unit 3 transv.pptxRosabel UA
 
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...JojoEDelaCruz
 
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxQ4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxlancelewisportillo
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Seán Kennedy
 

Recently uploaded (20)

Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4
 
Measures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped dataMeasures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped data
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
 
TEACHER REFLECTION FORM (NEW SET........).docx
TEACHER REFLECTION FORM (NEW SET........).docxTEACHER REFLECTION FORM (NEW SET........).docx
TEACHER REFLECTION FORM (NEW SET........).docx
 
Expanded definition: technical and operational
Expanded definition: technical and operationalExpanded definition: technical and operational
Expanded definition: technical and operational
 
Activity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translationActivity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translation
 
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptxLEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
 
EMBODO Lesson Plan Grade 9 Law of Sines.docx
EMBODO Lesson Plan Grade 9 Law of Sines.docxEMBODO Lesson Plan Grade 9 Law of Sines.docx
EMBODO Lesson Plan Grade 9 Law of Sines.docx
 
4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx
 
ClimART Action | eTwinning Project
ClimART Action    |    eTwinning ProjectClimART Action    |    eTwinning Project
ClimART Action | eTwinning Project
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management System
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 
Presentation Activity 2. Unit 3 transv.pptx
Presentation Activity 2. Unit 3 transv.pptxPresentation Activity 2. Unit 3 transv.pptx
Presentation Activity 2. Unit 3 transv.pptx
 
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
 
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxQ4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...
 
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptxYOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
 

Bubble sort a best presentation topic