Wednesday, 8 June 2022

Bubble Sort

 import java.util.Arrays;
public class Example4 {
public static void main(String[] args) {
int arr[] = { 10, 40, 4, 60, 5, 1 };

//10,4,40,5,1,60


bubbleSort(arr);

System.out.println(Arrays.toString(arr));
}

for(int j=0;j<input.length;j++)
{

for(int i=0;i<input.length-j-1;i++)
{
if(input[i]>input[i+1])
{
int temp=input[i];
input[i]=input[i+1];
input[i+1]=temp;

}
}
}
}



}


No comments:

Post a Comment

06/20/024 ( TODO)

Q1 : Create array , add element ,remove element , and update the element  Q2: Show me how overloading and overriding work in inheritance wit...