filmov
tv
Bubble Sort Algorithm | How Bubble Sort Works with Example | Part - 1 | Sorting Algorithms DS

Показать описание
Support Simple Snippets by Donations -
--------------------------------------------------------------------------------------------- Theory -
Bubble Sort is the simplest sorting algorithm that works by repeatedly swapping the adjacent elements if they are in wrong order.
his algorithm is suitable for small data sets
Its average and worst case complexity are of - (n^2) where n is the number of items.
It is known as bubble sort, because with every complete iteration the largest element bubbles up towards the last place or the highest index just like a water bubble rises up to the water surface.
Working -
Step 1 - Starting with the first element(index = 0), compare the current element with the next element of the array.
Step 2 - If the current element is greater than the next element of the array, swap them.
Step 3 - If the current element is less than the next element, move to the next element.
Step 4 - Repeat Step 1 till the list is sorted.
Simple Snippets Official Website -
Simple Snippets on Facebook -
Simple Snippets on Instagram -
Simple Snippets on Twitter -
Simple Snippets Google Plus Page -
Simple Snippets email ID -
--------------------------------------------------------------------------------------------- Theory -
Bubble Sort is the simplest sorting algorithm that works by repeatedly swapping the adjacent elements if they are in wrong order.
his algorithm is suitable for small data sets
Its average and worst case complexity are of - (n^2) where n is the number of items.
It is known as bubble sort, because with every complete iteration the largest element bubbles up towards the last place or the highest index just like a water bubble rises up to the water surface.
Working -
Step 1 - Starting with the first element(index = 0), compare the current element with the next element of the array.
Step 2 - If the current element is greater than the next element of the array, swap them.
Step 3 - If the current element is less than the next element, move to the next element.
Step 4 - Repeat Step 1 till the list is sorted.
Simple Snippets Official Website -
Simple Snippets on Facebook -
Simple Snippets on Instagram -
Simple Snippets on Twitter -
Simple Snippets Google Plus Page -
Simple Snippets email ID -
Комментарии