Sorting algorithms made easy
Visualize the step by step process of popular sorting algorithms!
How it Works

1. Select the Algorithm

Visualize the algorithm of your choice.

3. Start Sorting

Press the play button to start the step by step sorting process.

2. Select Settings

Adjust the speed of the visualizer and array size.

4. Fast-forward, Backtrack, and Replay

Replay the entire sorting process or walk through the algorithm one step at a time with these functions.

Visualizer
20
9
17
5
10
15
12
19
12
13
13
19
15
10
17

0%
Speed: 5
Size: 15
New Data
Legend
Currently involved in the swap process
Not involved in the swap process
How Bubble Sort works

Bubble Sort is the simplest sorting algorithm that works by repeatedly swapping adjacent elements if they are in the wrong order. This procedure is repeated until no swaps are required, indicating that the list has been sorted.

Performance

Assuming N is the size of array,

Worst time complexity

Average time complexity

Best time complexity

Worst space complexity

O(N2)

θ(N2)

Ω(N)

O(1)

Stable

In-place

Click for more info

Java

JavaScript

Python

C/C++

void swap(int[] arr, int i, int j) {
int temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
}
void bubbleSort(int[] arr) {
// Loop in the range of unsorted elements
for (int i = arr.length - 1; i >= 0; i--) {
boolean swapped = true;
// Bubble largest element to the end
for (int j = 0; j < i; j++) {
if (arr[j] > arr[j + 1]) {
swap(arr, j, j + 1);
swapped = false;
}
}
// Array is already sorted as there are no swaps in this iteration
if (swapped) {
break;
}
}
}
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Team

Meet our team

We are a group of highly motivated students from National University of Singapore that are invested in the field of software engineering and algorithms. Feel free to contact us to collaborate on interesting software engineering projects.

Lum Jian Yang Sean

Sophomore at National University of Singapore

Keane Chan Jun Yu

Sophomore at National University of Singapore

Lau Jun Hao Ashley

Sophomore at National University of Singapore

Contact Us
Do contact us if there is any error or improvement or wish to collaborate on this project
Type (Optional)