Main Method # 1

mail@pastecode.io avatar
unknown
java
a year ago
950 B
0
Indexable
Never
package LAB4;
import java.util.*;

public class Main1
{
    public static void main(String[] args)
    {
        // Initialize an array of integer values to be used for constructing the binary search tree
        int[] values = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};

        // Create a new BinarySearchTree object using the array of values
        BinarySearchTree myBST = new BinarySearchTree(values);

        // Get the Pre-order traversal result of the binary search tree
        ArrayList<Integer> preorder = myBST.DFSPreOrder();

        // Get the In-order traversal result of the binary search tree
        ArrayList<Integer> inorder = myBST.DFSInOrder();

        // Convert the Pre-order and In-order traversal results to Post-order traversal
        ArrayList<Integer> postorder = myBST.convertToPostOrder(preorder, inorder);

        // Print the Post-order traversal result
        System.out.println(postorder);
    }
}