You are on page 1of 6

BUBBLE SORT

ALGORITHM
WHAT IS BUBBLE SORT?
Bubble sort is a basic algorithm for arranging a string of
numbers or other elements in the correct order.

2
This algorithm consists of an outer iteration and an
inner iteration.

What are the 5 steps of bubble sort?


To perform a bubble sort, follow these steps in your programming or
scripting language.
 Start with an unsorted list.
 Compare the first two elements.
 Assess the second and third elements.
 Complete the first pass and evaluate the list.
 Continue making passes until fully sorted.
3
WHAT IS BUBBLE SORT STRUCTURE?
Bubble Sort is a simple sorting algorithm commonly used to sort elements in a list or array. It works
by repeatedly comparing adjacent elements and swapping them if they are in the wrong order. The
algorithm iterates through the list multiple times until no more swaps are needed, resulting in a
sorted sequence.

How many operations are there in


bubble sort?
For example bubble sort algorithm has a complexity of O(n^2). As
you see above, two loops are used to sort the array. Let
ARRAY_SIZE be n. Then the number of operations is n*(n-1).
W H AT I S B U B B L E S O R T I N G E X A M P L E S ?
This process is repeated until the list is sorted. For instance, if you have a list like this:
5, 3, 8, 4, 2, the Bubble Sort algorithm would start by comparing the first two numbers.
Since 5 is greater than 3, it would swap the two numbers. The list would become: 3, 5, 8,
4, 2.

5
THANK YOU

You might also like