|
|
|
|
||
|
|
Recursion and Quick Sort |
|
||
|
|
Introduction Recursion is a programming technique in which a method calls itself. It is key to the quick sort algorithm which is used in many programming applications to sort data in arrays. The timing “snippet” shown below can be used to test the efficiency of methods as we did in Chapter 6. |
|
||
|
|
long time; time = System.currentTimeMillis(); System.out.print(“System
time is milliseconds “); System.out.println(time); |
|
||
|
|
Programming Assignment Write two programs. Each will set up a large array of randomized integers. In the first program sort the integers in the array using the quick sort algorithm provided in the Java programming language. In the second program write a quick sort method of your own and sort the same array as in the first program. Compare the time of the two programs that it took to sort the array. |
|
||
|
|
|
|
||
|
|
|
|
||
|
|
|
|
||
|
|
|
|
||
|
|
|
|
||
|
|
|
|
||
|
|
|
|