KEMBAR78
Bubble Sort Algorithm Presentation | PPTX
Bubble Sort
PRESENTED BY: AHMED AL-BUTTY
Introduction to Sorting Algorithms
A sorting algorithm is a method for re-ordering a large
number of elements into a specific order, such as alphabetical,
highest-to-lowest value or shortest-to-longest distance.
Sorting algorithms take list of elements as input data, perform
specific operations on this list and deliver ordered array as
output. There are many applications of sorting algorithms
such as organizing items by price on a retail website and
determining the order of site on a search engine result page
What is Bubble Sort
It uses simple algorithm. It sorts by comparing each pair of
adjacent items and swapping them in the correct order and
start point is the first two elements( List[0] and List[1] ),
and end point are the last two elements ( List[n - 2] and List[n-1] ).
This will be repeated until no swaps are needed. Bubble sort is
often used to introduce the concept of a sorting algorithm, to
junior computer science students.
Bubble Sort Algorithm
1. In an unsorted array of 5 elements, start with the first two elements and
Compare them to be sorted in ascending order.
2. Compare the second and third element to check which one is greater, and
sort them in ascending order.
3. Compare the third and fourth element to check which one is greater, and
sort them in ascending order.
4. Compare the fourth and fifth element to check which one is greater, and
sort them in ascending order.
5. Repeat steps 1–5 until no more swaps are required.
Example of Bubble Sort
Complexity Analysis
Bubble sort has a worst-case and average time complexity of
О(𝑛2
), where n is the number of items being sorted. Most
practical sorting algorithms are better than bubble sort in
worst-case or average time complexity. Therefore, bubble sort
is not a practical sorting algorithm but it is good one if we use
it to sort small amount of data. In this case its complexity will
be O(n). and its worst-case space complexity is O(1)
When to Choose Bubble Sort
This algorithm has several advantages. It is simple to write,
easy to understand and it only takes a few lines of code. The
data is sorted in place, which means to produce an output in
the same memory space that contains the input by
transforming that data until the output is produced, so there
is little memory overhead, and it is efficient sorting algorithm
when we need to build mobile application if the device has
low RAM capacity.

Bubble Sort Algorithm Presentation

  • 1.
  • 2.
    Introduction to SortingAlgorithms A sorting algorithm is a method for re-ordering a large number of elements into a specific order, such as alphabetical, highest-to-lowest value or shortest-to-longest distance. Sorting algorithms take list of elements as input data, perform specific operations on this list and deliver ordered array as output. There are many applications of sorting algorithms such as organizing items by price on a retail website and determining the order of site on a search engine result page
  • 3.
    What is BubbleSort It uses simple algorithm. It sorts by comparing each pair of adjacent items and swapping them in the correct order and start point is the first two elements( List[0] and List[1] ), and end point are the last two elements ( List[n - 2] and List[n-1] ). This will be repeated until no swaps are needed. Bubble sort is often used to introduce the concept of a sorting algorithm, to junior computer science students.
  • 4.
    Bubble Sort Algorithm 1.In an unsorted array of 5 elements, start with the first two elements and Compare them to be sorted in ascending order. 2. Compare the second and third element to check which one is greater, and sort them in ascending order. 3. Compare the third and fourth element to check which one is greater, and sort them in ascending order. 4. Compare the fourth and fifth element to check which one is greater, and sort them in ascending order. 5. Repeat steps 1–5 until no more swaps are required.
  • 5.
  • 6.
    Complexity Analysis Bubble sorthas a worst-case and average time complexity of О(𝑛2 ), where n is the number of items being sorted. Most practical sorting algorithms are better than bubble sort in worst-case or average time complexity. Therefore, bubble sort is not a practical sorting algorithm but it is good one if we use it to sort small amount of data. In this case its complexity will be O(n). and its worst-case space complexity is O(1)
  • 7.
    When to ChooseBubble Sort This algorithm has several advantages. It is simple to write, easy to understand and it only takes a few lines of code. The data is sorted in place, which means to produce an output in the same memory space that contains the input by transforming that data until the output is produced, so there is little memory overhead, and it is efficient sorting algorithm when we need to build mobile application if the device has low RAM capacity.