This project is a C++ command interpreter for classic data structures: AVL Tree, Graph, Hash Table, Min Heap, and Max Heap. It reads commands from a file, executes them on the corresponding data structure, and writes results to an output file. The project is designed for educational and demonstration purposes.
-
Command Input:
- The interpreter reads commands from
commands.txt. - Each command specifies an operation (e.g., build, insert, delete, search) and the target data structure.
- The interpreter reads commands from
-
Supported Data Structures:
- AVL Tree
- Graph
- Hash Table
- Min Heap
- Max Heap
-
Supported Commands:
BUILD <DATA_STRUCTURE> <FILENAME>: Build the structure from a file.GETSIZE <DATA_STRUCTURE>: Get the number of elements (or vertices/edges for Graph).FINDMIN <MINHEAP/AVLTREE>: Find the minimum element.FINDMAX <MAXHEAP>: Find the maximum element.SEARCH <DATA_STRUCTURE> <VALUE>: Search for a value.INSERT <DATA_STRUCTURE> <VALUE...>: Insert a value (or edge for Graph).DELETE <DATA_STRUCTURE> <VALUE...>: Delete a value (or edge for Graph).DELETEMIN <MINHEAP>: Remove the minimum element.DELETEMAX <MAXHEAP>: Remove the maximum element.COMPUTESHORTESTPATH <GRAPH> <START> <END>: Compute shortest path in a graph.COMPUTESPANNINGTREE <GRAPH>: Compute minimum spanning tree cost.FINDCONNECTEDCOMPONENTS <GRAPH>: Find the number of connected components.
-
Output:
- Results are written to
output.txt. - Each command's execution time (in microseconds) is logged.
- Results are written to
-
Example Workflow:
- Place your commands in
commands.txt. - Place any required data files (e.g., for building structures) in the project directory.
- Run the compiled executable. Check
output.txtfor results.
- Place your commands in
main.cpp: Command interpreter and program entry pointAVLTree.cpp,Graph.cpp,HashTable.cpp,MinHeap.cpp,MaxHeap.cpp: Data structure implementationstest1/,test2/, ...: Example input/output and data filesCMakeLists.txt: Build configuration
BUILD AVLTREE avltree.txt
INSERT AVLTREE 42
SEARCH AVLTREE 42
GETSIZE AVLTREE
See LICENSE for details.