Binary Search Tree Program
A fully custom Java-based implementation of a Binary Search Tree that fulfills the Java Set interface while also providing a live UI and BST visualizer. This project was designed to support a larger game project, where maintaining and organizing large collections of enum values required an efficient and structured backend solution. The BSTSet program ensures all string-based elements remain sorted, unique, and accessible in logarithmic time.
The visual interface allows users to insert, remove, and check elements with real-time feedback, offering an educational view into how binary trees operate. It supports in-order traversal for sorted output, full recursive logic for add, remove, contains, and size, and shows the structural changes dynamically through animated tree drawing. The UI also supports automatic save/load functionality via .dat file serialization, making it possible to resume previous sessions instantly.
Key features include:
- Full compliance with the Java Set interface
- Recursive methods for all tree operations, preserving balance and uniqueness
- Real-time visualizer that animates tree growth, removal, and traversal
- A graphical user interface for input/output
- Object serialization using Java’s I/O libraries to persist the tree state between runs
This tool was invaluable for backend enum organization in a custom RPG game and serves as both a practical utility and a learning resource for data structures and recursion.
Technologies Used:
Java Core Libraries:
Implements Set and Serializable interfaces to manage collections and persist data.
Binary Search Tree (BST):
Supports recursive add(), remove(), contains(), size(), and in-order traversal to maintain order and uniqueness.
Java Swing GUI:
Built with JFrame, JPanel, JButton, JTextField, and JOptionPane for real-time interaction and visualization.
Event-Driven Programming:
Uses ActionListener for user input and WindowAdapter to save data on exit.
File I/O & Serialization:
Saves and loads tree state with ObjectOutputStream and ObjectInputStream.
String Handling:
Case-insensitive logic with utility-based proper casing for display.