What is a bubble sort in java?
Answer / Avlokna Agarwal
Bubble Sort is a simple sorting algorithm that repeatedly steps through the list, compares adjacent elements and swaps them if they are in the wrong order. Here's an example:
```java
void bubbleSort(int[] arr) {
int n = arr.length;
for (int i = 0; i < n-1; i++) {
for (int j = 0; j < n-i-1; j++) {
if (arr[j] > arr[j+1]) {
// swap arr[j] and arr[j+1]
}
}
}
}
| Is This Answer Correct ? | 0 Yes | 0 No |
Difference between JVM and JRE?
Can we rethrow the same exception from catch handler?
What is r * in math?
What is contract between hashcode and equal method?
How do I compare two strings in word in java?
How to find the size of an array a)array.length() b)array.length c)array.size() d)array.size
How big is a pointer?
can we have virtual functions in java?
How do you add an element to an arraylist in java?
What is an object in Java and what are its benefits?
How many types of thread in java? give the name
what is collatration?