COP3530/Project11/Project11.cpp
Fennel Kora 4f6ac0f79f Add project 11
project 11 is incomplete - framework exists but logic for correctly counting the shortest branch doesn't appear to return a correct value (always 3)
2023-07-24 10:32:56 -04:00

32 lines
No EOL
888 B
C++

// Corey Williams
// COP3530 01Z
// Project 11
/*
Write an application, that calls a recursive method, “shortestBranch” (i.e., must be written)
and displays the depth to the shallowest node of the binary tree.
*/
/* Note - Project is incomplete - I had difficulty in returning what I believe to be
the correct depth via the recursive shortestBranch function added in genBST11.h, but am
submitting to show work done for partial credit.*/
using namespace std;
#include <iostream>
#include "genBST11.h"
#include <vector>
int main() {
vector<int> inputs = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25};
BST<int> tree;
for (auto i = inputs.begin(); i != inputs.end(); i++) {
tree.insert(*i);
}
cout << "Nodes:\n";
tree.inorder();
cout << "\nThe shortest branch has " << tree.shortestBranch(tree.getRoot(), 1) << " nodes.\n";
}