Sorting Algorithm Lect4
Sorting Algorithm Lect4
Elham Rezaie
CONTENTS
1 Sorting algorithm
2 implementation
What is Bubble Sort in C++?
• Bubble Sort in C++, is one of the popular sorting techniques, that we
use in data structures. The logical arranging of data is known as
sorting. Using the algorithm of bubble sort we can sort any linear
data structure
• The logical sorting order can be ascending or descending.
• This is a simple sorting algorithm but it is not the best.
Steps to implement bubble sort
1. Linearly Traverse array from left
2. If the rst item is greater than the 2nd item in the array, swap them.
• That is, arr[i] > arr[i+1], then swap
3. Now, compare the next two elements.
4. We will repeat all the previous steps until the given array is sorted.
Thanks
Study hard and Make
progress every day
Elham Rezaie