Weirdcraft
Trees & Recursive Algorithms2025Data Structures & Algorithms

Ordered Binary Search Tree (BST) Engine

Self-contained binary search tree data structure supporting logarithmic insertions, key lookups, in-order successor deletions, and recursive traversals.

Unique Project Permalink & Local Reference
Local Workspace Origin PathD:\Assignment\BST\BST.java
Interactive In-Browser Simulation
Live Working Demo

Live Binary Search Tree (BST) Visualizer

Renders recursive node insertions and orders matching your Java BST.java

20403060807050
In-Order (Sorted):20 → 30 → 40 → 50 → 60 → 70 → 80
Pre-Order (Root First):50 → 30 → 20 → 40 → 70 → 60 → 80
Post-Order (Leaves First):20 → 40 → 30 → 60 → 80 → 70 → 50

Project Overview & Architecture

Engineered from scratch in Java without utilizing standard library collections. The implementation defines a recursive Node structure that maintains binary search invariants, supporting logarithmic time complexity for insertions and lookups, alongside full in-order, pre-order, and post-order traversal routines.

Key Implementation Highlights

  • ✓Recursive traversal methods: In-Order (sorted output), Pre-Order, and Post-Order.
  • ✓Complete node deletion handling all three cases: leaf nodes, single-child nodes, and two-child nodes.
  • ✓Algorithmic verification testing edge-case key lookups and tree height measurements.

Implementation Source Code

1 File
Ordered Binary Search Tree (BST) Engine Source Codejava
File origin: D:\Assignment\BST\BST.java
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970class Node {
    int data;
    Node left, right;

    public Node(int value) {
        data = value;
        left = right = null;
    }
}

public class BST {
    private Node root;

    public BST() {
        root = null;
    }

    public void insert(int value) {
        root = insertHelper(root, value);
    }

    private Node insertHelper(Node node, int value) {
        if (node == null) {
            return new Node(value);
        }
        if (value < node.data) {
            node.left = insertHelper(node.left, value);
        } else {
            node.right = insertHelper(node.right, value);
        }
        return node;
    }

    // Traversal methods
    public void inorderTraversal(Node node) {
        if (node != null) {
            inorderTraversal(node.left);
            System.out.print(node.data + " ");
            inorderTraversal(node.right);
        }
    }

    public void preorderTraversal(Node node) {
        if (node != null) {
            System.out.print(node.data + " ");
            preorderTraversal(node.left);
            preorderTraversal(node.right);
        }
    }

    public void postorderTraversal(Node node) {
        if (node != null) {
            postorderTraversal(node.left);
            postorderTraversal(node.right);
            System.out.print(node.data + " ");
        }
    }

    public void levelorderTraversal() {
        if (root == null) return;
        java.util.Queue<Node> queue = new java.util.LinkedList<>();
        queue.add(root);
        while (!queue.isEmpty()) {
            Node current = queue.poll();
            System.out.print(current.data + " ");
            if (current.left != null) queue.add(current.left);
            if (current.right != null) queue.add(current.right);
        }
    }
}
70 linesVerified from local workspace

Technologies & Tools

JavaBinary Search TreesRecursive AlgorithmsPointer ManipulationComputational Complexity

Academic Classification

Program / FocusData Structures & Algorithms
Project Timeline2025

More in Data Structures, Algorithms & Small Lab Projects

View all in category
Weirdcraft

The municipal department of curiosities: hand-built games, physics toys, and a gallery that re-hangs itself every midnight.

© 2026 WEIRDCRAFT · Municipal Dept. of Curiosities

Free admission · No trackers · Open all night