public class TestAVLTree {
  public static void main(String[] args) {
    // Tworzenie drzewa AVL 
    AVLTree<Integer> tree = new AVLTree<>(new Integer[]{25, 
      20, 5});
    System.out.print("Po wstawieniu 25, 20 i 5:");
    printTree(tree);

    tree.insert(34);
    tree.insert(50);
    System.out.print("\nPo wstawieniu 34 i 50:");
    printTree(tree);

    tree.insert(30);
    System.out.print("\nPo wstawieniu 30:");
    printTree(tree);

    tree.insert(10);
    System.out.print("\nPo wstawieniu 10:");
    printTree(tree);

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

    tree.delete(5);
    System.out.print("\nPo usunięciu 5:");
    printTree(tree);
    
    System.out.print("\nPobieranie elementów drzewa: ");
    for (int e: tree) {
      System.out.print(e + " ");
    }
  }

  public static void printTree(BST tree) {
    // Przechodzenie drzewa
    System.out.print("\nInorder (posortowane): ");
    tree.inorder();
    System.out.print("\nPostorder: ");
    tree.postorder();
    System.out.print("\nPreorder: ");
    tree.preorder();
    System.out.print("\nLiczba węzłów: " + tree.getSize());
    System.out.println();
  }
}
