The best way to understand complex data structures
is to see them in action. This project is developed
in an
interactive animations for a variety of data
structures and algorithms.
Delay Time :
10Array Size :
10
Defination :
Bubble sort
is a simple sorting algorithm. The algorithm starts at
the beginning of the data set. It compares the first two
elements, and if the first is greater than the second,
it swaps them. It continues doing this for each pair of
adjacent elements to the end of the data set. It then
starts again with the first two elements, repeating
until no swaps have occurred on the last pass.
Performance
Best-case Time complexity:
O(n²)
Average-case Time complexity:
O(n²)
worst-case Time complexity:
O(n)
Space complexity
worst-case Space complexity:
O(1)
async function bubbelSort(Arr){
for (var i = len-1; i>=0; i--){
for(var j = 1; j<=i; j++){
if(Arr[j-1]>Arr[j]){
swapIndex(Arr,j,j-1);
await drawArr(Arr);
await sleep(time);
}
}
}
}
Designed and built with by The ThunderBolt