part 3 complete

This commit is contained in:
Christopher Sanden
2025-11-08 14:51:28 +01:00
parent d6d627adad
commit 730987913e
10 changed files with 377 additions and 94 deletions

View File

@@ -3,6 +3,7 @@
#include <limits>
int RunApp() {
//Reading names from file for BST population
bst = new TBST();
/* Path to the names data file
This is MY absolute path -- change to your local path for this to read properly
@@ -11,6 +12,8 @@ int RunApp() {
const std::string filename = "C:\\Users\\csand\\IKT203\\Exam\\IKT203Exam\\DATA\\random_names.txt";
readNamesFromFile(filename, onNameRead);
// BST traversal -- comment out the entire block
// when done inspecting for more manageable terminal output
pack("Inorder traversal (sorted by ID)");
bst->Inorder();
@@ -44,8 +47,36 @@ int RunApp() {
else
std::cout << "ID not found\n" << std::endl;
bst->Inorder();
// End of BST block
// Start of AVL block
// Again, comment out the block if terminal output is
// too noisy
pack("AVL");
avl = new TAVL;
TAVL::Populate(avl, 100, 1, 200);
pack("Inorder");
avl->PrintOrder(TAVL::Inorder);
pack("Postorder");
avl->PrintOrder(TAVL::Postorder);
pack("Preorder");
avl->PrintOrder(TAVL::Preorder);
pack("Levelorder");
avl->PrintOrder(TAVL::LevelOrder);
// End of AVL block
// Cleaning to free up memory.
// Used only at end of runtime, but useful for when runtime needs
// to be continuous
pack ("Cleaning up");
delete bst;
delete avl;
return 0;
}