import.java.io.*;
import.java.util.*;
class Bubblesort
{
public.static void main (string args[])
throw io exception, array index bounds exception
{
int num;
system.out.println ("bubble sort");
system.out.println ("enter number of elements");
scanner - input = new scanner (system.in);
num = input - next.int ();
bubble impl impl = new bubble impl (num);
system.out.println ("enter element to sort");
for (int i = 0; i < num, i++)
impl.A[i] = input.next.int ());
impl.bubble sort (num);
impl.display (num);
}
}
class bubble impl;
{
int n;
int[]A bubble impl (int[max])
{
A = new int[max]}
void bubble sort (int n)
{
int temp;
int swap = 0;
for (int j = 0; j <= n - 2, j++)
{
if A
[j] < A[j + 1]
{
temp = A[j];
A[j] = A[j + 1];
A[j + 1] = temp;
systemm.out.println ("array element at" + s + position + A[J]);
system.out.println ("array element at" + (J + 1) + position +
A[j + 1]) swap++;
}
}
}
system.out.println ("no.of interchanges are" + (swap));
}
void display (intn)
{
system.out.println ("/n sorted list is");
for (int i = 0; i < n; i++)
system.out.println ("position" + A[j]);
}
}