| 65 | } |
| 66 | |
| 67 | public static void main(String[] args) { |
| 68 | TreeSort treeSort = new TreeSort(); |
| 69 | |
| 70 | // ==== Integer Array ======= |
| 71 | System.out.println("Testing for Integer Array...."); |
| 72 | Integer[] a = {3, -7, 45, 1, 343, -5, 2, 9}; |
| 73 | System.out.printf("%-10s", "unsorted: "); |
| 74 | print(a); |
| 75 | a = treeSort.sort(a); |
| 76 | System.out.printf("%-10s", "sorted: "); |
| 77 | print(a); |
| 78 | System.out.println(); |
| 79 | |
| 80 | // ==== Integer List ======= |
| 81 | System.out.println("Testing for Integer List...."); |
| 82 | List<Integer> intList = List.of(3, -7, 45, 1, 343, -5, 2, 9); |
| 83 | System.out.printf("%-10s", "unsorted: "); |
| 84 | print(intList); |
| 85 | intList = treeSort.sort(intList); |
| 86 | System.out.printf("%-10s", "sorted: "); |
| 87 | print(intList); |
| 88 | System.out.println(); |
| 89 | |
| 90 | // ==== String Array ======= |
| 91 | System.out.println("Testing for String Array...."); |
| 92 | String[] b = { |
| 93 | "banana", |
| 94 | "berry", |
| 95 | "orange", |
| 96 | "grape", |
| 97 | "peach", |
| 98 | "cherry", |
| 99 | "apple", |
| 100 | "pineapple", |
| 101 | }; |
| 102 | System.out.printf("%-10s", "unsorted: "); |
| 103 | print(b); |
| 104 | b = treeSort.sort(b); |
| 105 | System.out.printf("%-10s", "sorted: "); |
| 106 | print(b); |
| 107 | System.out.println(); |
| 108 | |
| 109 | // ==== String List ======= |
| 110 | System.out.println("Testing for String List...."); |
| 111 | List<String> stringList = List.of("banana", "berry", "orange", "grape", "peach", "cherry", "apple", "pineapple"); |
| 112 | System.out.printf("%-10s", "unsorted: "); |
| 113 | print(stringList); |
| 114 | stringList = treeSort.sort(stringList); |
| 115 | System.out.printf("%-10s", "sorted: "); |
| 116 | print(stringList); |
| 117 | } |
| 118 | } |