javasort - A[i] = R.nextInt(); for (int i=0; i<n;i++)...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
import java.io.*; import java.util.*; public class javasort { public static void main(String[] args) throws Exception { long begin, end; begin = System.currentTimeMillis(); int n = Integer.parseInt(args[0]); int[] A = new int[n]; Random R = new Random(); for (int i=0;i<n;i++)
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: A[i] = R.nextInt(); for (int i=0; i<n;i++) for (int j=0; j<n-1;j++) if (A[j+1]<A[j]) {int temp = A[j]; A[j] = A[j+1]; A[j+1] = temp; } end = System.currentTimeMillis(); System.out.println("The elapsed time is " + (end-begin)/1000); } }...
View Full Document

This note was uploaded on 11/27/2009 for the course CS 123 taught by Professor Bajkzek during the Spring '08 term at Carnegie Mellon.

Ask a homework question - tutors are online