Java Practicals Data Structures

Embed Size (px)

Citation preview

1B.Sc (Computer Sc ience) Object Oriente d Programming with Java and Data Structures Lab Programs- Data Structures

1. Program to impleme nt Bubble Sort. import java.io.*; class Prog37 { public static void main(String[] args) throws IOException { System.out.println("How many values do u want:"); BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); int n=Integer.parseInt(br.readLine()); int arr[]=new int[n]; System.out.println("Enter " + n + " numbers:"); int temp; for(int i=0;i1;j--) for(int k=0;karr[k+1]) { temp=arr[k]; arr[k]=arr[k+1]; arr[k+1]=temp; } System.out.println("Bubble Sorted List:"); for(int i=0;i