/*
This program creates and initializes a linked list. The reverseorder () method returns a comparator function that reversely compares integer objects. The elements in the list are sorted by the comparison function and displayed. Next, call the shuffle () method to randomly arrange the list, and then display the maximum and minimum values of the list.
*/
// Demonstrate various algorithms.
Import java. util .*;
Class algorithmdemo {
Public static void main (string [] ARGs)
{
// Create and initialize linked list.
Counter list LL = new counter list ();
Ll. Add (New INTEGER (-9 ));
Ll. Add (New INTEGER (10 ));
Ll. Add (New INTEGER (-10 ));
Ll. Add (New INTEGER (9 ));
Ll. Add (New INTEGER (99 ));
Ll. Add (New INTEGER (100 ));
// Create a reverse order comparator.
Comparator r = collections. reverseorder ();
// Sort list by using the comparator.
Collections. Sort (LL, R );
// Get an iterator.
Iterator I = ll. iterator ();
System. Out. println ("list sorted in reverse :");
While (I. hasnext ()){
System. Out. println (I. Next () + "");
}
System. Out. println ();
Collections. Shuffle (LL );
// Display randomized list
I = ll. iterator ();
System. Out. Print ("list shuffled :");
While (I. hasnext ()){
System. Out. Print (I. Next () + "");
}
System. Out. println ();
System. Out. println ("minimum:" + collections. Min (LL ));
System. Out. println ("Maximum:" + collections. Max (LL ));
}
}