public class TestTree24 {
  public static void main(String[] args) {
    // Tworzenie drzewa 2-3-4
    Tree24<Integer> tree = new Tree24<>();

    tree.insert(34);
    tree.insert(3);
    tree.insert(50);
    tree.insert(20);
    tree.insert(15);
    tree.insert(16);
    tree.insert(25);
    tree.insert(27);
    tree.insert(29);
    tree.insert(24);
    System.out.print("\nPo wstawieniu 24:");
    printTree(tree);
    tree.insert(23);
    tree.insert(22);
    tree.insert(60);
    tree.insert(70);
    System.out.print("\nPo wstawieniu 70:");
    printTree(tree);

    tree.delete(34);
    System.out.print("\nPo usunięciu 34:");
    printTree(tree);

    tree.delete(25);
    System.out.print("\nPo usunięciu 25:");
    printTree(tree);

    tree.delete(50);
    System.out.print("\nPo usunięciu 50:");
    printTree(tree);

    tree.delete(16);
    System.out.print("\nPo usunięciu 16:");
    printTree(tree);

    tree.delete(3);
    System.out.print("\nPo usunięciu 3:");
    printTree(tree);

    tree.delete(15);
    System.out.print("\nPo usunięciu 15:");
    printTree(tree);
  }

  public static <E extends Comparable<E>>
      void printTree(Tree<E> tree) {
    // Przechodzenie drzewa
    System.out.print("\nPreorder: ");
    tree.preorder();
    System.out.print("\nLiczba węzłów: " + tree.getSize());
    System.out.println();
  }
}
