1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | import java.util.ArrayList; import java.util.Arrays; import java.util.Random; public class sortvsparllelsort { public static void main(String[] args) { Random random=new Random(); System.out.println("Comparison between Sort and Parallel Sort"); ArrayList<Integer> arraylist=new ArrayList<>(); for (long i=1;i<10000000L;i++) {arraylist.add(random.nextInt(900)); } System.out.println("ArrayList has been initialised"); Integer a[]=new Integer[arraylist.size()]; Integer b[]=new Integer[arraylist.size()]; System.out.println("Both normal arrays are initialised"); a= arraylist.toArray(a); b=Arrays.copyOf(a,a.length); System.out.println("comparison starting "); double start,end,sorttime,parallelsorttime; System.out.print("Time taken by Sort method="); start=System.nanoTime(); Arrays.sort(a); end=System.nanoTime(); sorttime=(end-start)/(Math.pow(10,9)); System.out.println( sorttime +" Seconds"); System.out.print("Time taken by parallel sort ="); start=System.nanoTime(); Arrays.parallelSort(b); end=System.nanoTime(); parallelsorttime=(end-start)/(Math.pow(10,9) ); System.out.println(parallelsorttime +" Seconds"); String verdict=""; verdict=sorttime>parallelsorttime?"ParallelSort ":"Sort "; verdict+=" IS BETTER than "; verdict+=sorttime>parallelsorttime?"Sort ":"ParallelSort"; System.out.println(verdict.trim()); } } |
QWERTY QWERTY / ˈ k w ɜr t i / is the most common modern-day keyboard layout . The name comes from the first six keys appearing on the top left letter row of the keyboard and read from left to right: Q-W-E-R-T-Y. The QWERTY design is based on a layout created for the Sholes and Glidden typewriter and sold to Remington in 1873. It became popular with the success of the Remington No. 2 of 1878, and remains in use on electronic keyboards due to the network effect of a standard layout and a belief that alternatives fail to provide very significant advantages. [ 1 ] The use and adoption of the QWERTY keyboard is often viewed as one of the most important case studies in open standards because of the widespread, collective adoption and use of the product. [ 2 ] History and purposes [ edit ] Keys are arranged on diagonal columns, to give space for the levers. Main article: Sholes and Glidden typewriter Still used to this day, the QWERTY layout was devised
Comments
Post a Comment
share your thoughts ....