Java Reference
In-Depth Information
System.out.println();
}
}
// Add the integers to first tree
for(int number: numbers) {
((BinaryTree<Integer>)trees[0]).add(number);
}
// Create an array of words to be sorted
String[] words = {"vacillate", "procrastinate", "arboreal",
"syzygy",
"xenocracy", "zygote", "mephitic", "soporific",
"grisly", "gristly" };
// List the words
System.out.println("\nOriginal word sequence:");
for(String word : words) {
System.out.printf("%-15s", word);
if(++count%5 == 0) {
System.out.println();
}
}
// Insert the words into second tree
for(String word : words) {
((BinaryTree<String>)trees[1]).add(word);
}
// Sort the values in both trees
for(int i = 0 ; i < lists.length ; ++i){
lists[i] = trees[i].sort();
}
// List the sorted values from both trees
for(LinkedList<?> list : lists){
System.out.println("\nSorted results:");
listAll(list);
}
}
// List the elements in any linked list
public static void listAll(LinkedList<?> list) {
for(Object obj : list) {
System.out.println(obj);
}
}
}
Directory "TryWildcardArray"
Search WWH ::




Custom Search