| Author |
how do you sort the array into ascending orde
|
nalamati satyanarayana
Ranch Hand
Joined: Dec 16, 2005
Posts: 36
|
|
public class SortSample { public void printSorted(int arrayToSort[]) { .. // Insert code to sort the array here System.out.print("Sorted array is "); for (int j = 0; j < arrayToSort.length; j++) System.out.print(arrayToSort[j] + " "); System.out.println(); } Question In the above code, with the minimum of coding, how do you sort the array into ascending order? Choice 1 Call java.util.Arrays.sort(arrayToSort). Choice 2 Load the array values into a SortedList collection, then unload them back into the array in order. Choice 3 Call java.util.Collections.sort(ArrayToSort). Choice 4 Write a Shell-Metzner sort routine since we do not know the length of the array. Choice 5 Write a bubble sort routine.
|
 |
Svend Rost
Ranch Hand
Joined: Oct 23, 2002
Posts: 904
|
|
I'll tel you how to solve your problem... Its actually easy.. find out what 1,2,3,4 and 5 does - and you have the answer. The answers for 1,2 and 3can be found in the Java API and 4 and 5 can be found in a introductory book on algorithms (or using google). /Svend Rost [ March 07, 2007: Message edited by: Svend Rost ]
|
 |
Christophe Verré
Sheriff
Joined: Nov 24, 2005
Posts: 14672
|
|
|
I'm wondering why he's only posting exam questions without even telling what his doubt is... I don't think the ranch is an answering machine
|
[My Blog]
All roads lead to JavaRanch
|
 |
 |
|
|
subject: how do you sort the array into ascending orde
|
|
|