Published on

close up of circuit board

What is bubble code ?

Bubble sort, sometimes referred to as sinking sort A bubble sort is an internal exchange sort. It is considered one of the simplest methods to sort an array of objects.

Who invented the bubble sort?

Iverson The term “Bubble Sort” was first used by Iverson in 1962.

Why is it called Bubble Sort?

Why bubble sort is called “bubble” sort? The “bubble” sort is called so because the list elements with greater value than their surrounding elements “bubble” towards the end of the list. For example, after first pass, the largest element is bubbled towards the right most position.

What does bubble sort do ?

R epeatedly steps through the list, compares adjacent elements and swaps them if they are in the wrong order. The pass through the list is repeated until the list is sorted.

Why do we use ?

We use bubble sort to chronologically sort a list of values in ascending order . It has the same level of efficiency as selection sort . Bubble Sort is a sorting algorithm that works by repeatedly stepping through lists that need to be sorted, comparing each pair of adjacent items and swapping them if they are in the wrong order. This passing procedure is repeated until no swaps are required, indicating that the list is sorted.

Biggest Advantage of a Bubble Sort

One of the main advantages of a bubble sort is that it is a very simple algorithm to describe to a computer. There is only really one task to perform (compare two values and, if needed, swap them). This makes for a very small and simple computer program .

How to use bubble sort

First we get the unsorted arrays Then the Bubble sort starts with very first two elements, comparing them to check which one is greater. If the first array is is greater then we swap the arrays and continue that process until the largest value is at the end Then the loop starts from the beginning then sorts and repeats until the arrays are in ascending order.

Example code

public void bubbleSort (int[]array) for(int i =0;i< array.length;i ++) for(int j=1;j<( i-i ); j++ ) if ( arr [j-1]> arr [j])

Thank you <3