From c6c1d31c389e80fe3763ed255dc8e2b307ef7efa Mon Sep 17 00:00:00 2001 From: Zachary Danz Date: Thu, 1 Mar 2018 12:31:18 -0500 Subject: [PATCH 1/5] rewrite of remove in AVLTree.cpp to fix memory leak, separation of headers to separate files, writting of node classes to avoid extraneous work --- labs/lab05/code/postlab/AVLNode.cpp | 34 +++++ labs/lab05/code/postlab/AVLNode.h | 19 +++ labs/lab05/code/postlab/AVLTree.cpp | 138 +++++++++++++-------- labs/lab05/code/postlab/AVLTree.h | 21 ++-- labs/lab05/code/postlab/BinaryNode.cpp | 21 ++++ labs/lab05/code/postlab/BinaryNode.h | 17 +++ labs/lab05/code/postlab/BinarySearchTree.h | 12 +- 7 files changed, 186 insertions(+), 76 deletions(-) create mode 100644 labs/lab05/code/postlab/AVLNode.cpp create mode 100644 labs/lab05/code/postlab/AVLNode.h create mode 100644 labs/lab05/code/postlab/BinaryNode.cpp create mode 100644 labs/lab05/code/postlab/BinaryNode.h diff --git a/labs/lab05/code/postlab/AVLNode.cpp b/labs/lab05/code/postlab/AVLNode.cpp new file mode 100644 index 000000000..43f96bb29 --- /dev/null +++ b/labs/lab05/code/postlab/AVLNode.cpp @@ -0,0 +1,34 @@ +#include "AVLNode.h" +#include + +using namespace std; + +AVLNode::AVLNode() +{ + value = ""; + left = NULL; + right = NULL; + height = 0; +} + +AVLNode::~AVLNode() +{ + delete left; + delete right; + + // to avoid crash on double deletes + left = NULL; + right = NULL; +} + +AVLNode& AVLNode::operator=(const AVLNode& other) +{ + if (this != &other) + { + this->value = other.value; + this->left = other.left; + this->right = other.right; + this->height = other.height; + } + return *this; +} \ No newline at end of file diff --git a/labs/lab05/code/postlab/AVLNode.h b/labs/lab05/code/postlab/AVLNode.h new file mode 100644 index 000000000..25ae69e01 --- /dev/null +++ b/labs/lab05/code/postlab/AVLNode.h @@ -0,0 +1,19 @@ +#ifndef AVL_NODE +#define AVL_NODE + +#include + +class AVLNode { + AVLNode(); + ~AVLNode(); + AVLNode& operator=(const AVLNode& other); + + std::string value; + AVLNode* left; + AVLNode* right; + int depth; + + friend class AVLTree; +}; + +#endif //AVL_NODE \ No newline at end of file diff --git a/labs/lab05/code/postlab/AVLTree.cpp b/labs/lab05/code/postlab/AVLTree.cpp index 94aaaa79f..69dd60884 100644 --- a/labs/lab05/code/postlab/AVLTree.cpp +++ b/labs/lab05/code/postlab/AVLTree.cpp @@ -1,66 +1,89 @@ +// Feel free to edit this file and add functions as necessary + #include "AVLTree.h" +#include "AVLNode.h" #include using namespace std; -// Implement the following -AVLNode::AVLNode() {} -AVLTree::AVLTree() {} -AVLTree::~AVLTree() {} -void AVLTree::insert(const string& x) {} -string pathTo(const string& x) const {} -bool find(const string& x) const {} -int numNodes() const {} -void balance(AVLNode*& n) {} -AVLNode* rotateLeft(AVLNode*& n) {} -AVLNode* rotateRight(AVLNode*& n) {} +// Implement at least the remaining unimplemented methods in AVLTree.h (see below method skeletons) +AVLTree::AVLTree() { } + +AVLTree::~AVLTree() { } + +void AVLTree::insert(const string& x) { } +string AVLTree::pathTo(const string& x) const { } +bool AVLTree::find(const string& x) const { } +int AVLTree::numNodes() const { } +void AVLTree::balance(AVLNode*& n) { } +AVLNode* AVLTree::rotateLeft(AVLNode*& n) { } +AVLNode* AVLTree::rotateRight(AVLNode*& n) { } -// The following are implemented for you -// remove finds x's position in the tree and removes it, rebalancing as -// necessary. -void AVLTree::remove(const string& x) { root = remove(root, x); } +/** The following are implemented for you: remove, max, min, and height; +remove finds x's position in the tree and removes it, rebalancing as necessary. **/ +void AVLTree::remove(const string& x) { if(remove(root, x)) balance(root); } -// private helper for remove to allow recursion over different nodes. returns -// an AVLNode* that is assigned to the original node. -AVLNode* AVLTree::remove(AVLNode*& n, const string& x) { - if (n == NULL) { - return NULL; +/** private helper for remove to allow recursion over different nodes; +returns an AVLNode* that is assigned to the original node. **/ +bool AVLTree::remove(AVLNode*& current, const string& x) { + // base-case for x not present in tree + if (current == NULL) + { + return false; } - // first look for x - if (x == n->value) { - // found + // recursively approach base case to left + else if (x < current->value) + { + return remove(current->left, x); + } + // recursively approach base case to right + else if (x > current->value) + { + return remove(current->right, x); + } + // base-case for x present in tree + else + { // no children - if (n->left == NULL && n->right == NULL) { - delete n; - return NULL; + if(current->left == NULL && current->right == NULL) + { + delete current; + current = NULL; + return (current == NULL); // should be true } - // single child - if (n->left == NULL) { - return n->right; + // two children + else if (current-> left != NULL && current->right != NULL) + { + AVLNode *rLMost = current->right; + // find leftmost node in right subtree iteratively + // this value is the lowest of the values higher than our current value + // i.e. the middle-most value of this (sub)tree + while(rLMost->left != NULL) + { + rLMost = rLMost->left; + } + // replace current with rLMost (value only) + current->value = rLMost->value; + // this should immediately reach either base-case present + // with (above) no children or (below) one child, the right + // just one more recurse. + return remove(rLMost, rLMost->value); } - if (n->right == NULL) { - return n->left; + // one child + else + { + // if right is not null, then child is right; otherwise child is left + AVLNode* child = (current->right != NULL) ? current->right : current->left; + // replace current with child but keep height + int heightTemp = current->height; + current = child; + current->height = heightTemp; + delete child; + child = NULL; + return (child == NULL); //should be true } - // two children -- tree may become unbalanced after deleting n - string sr = min(n->right); - n->value = sr; - n->right = remove(n->right, sr); - } else if (x < n->value) { - n->left = remove(n->left, x); - } else { - n->right = remove(n->right, x); } - n->height = 1 + max(height(n->left), height(n->right)); - balance(n); - return n; -} - -// max returns the greater of two integers. -int max(int a, int b) { - if (a > b) { - return a; - } - return b; + // recall that if this returns true, balance(root) will be called, fixing any inbalance } // min finds the string with the smallest value in a subtree. @@ -72,11 +95,20 @@ string AVLTree::min(AVLNode* node) const { return min(node->left); } -// height returns the value of the height field in a node. If the node is -// null, it returns -1. +/** height returns the value of the height field in a node. +If the node is null, it returns 0. **/ int AVLTree::height(AVLNode* node) const { if (node == NULL) { - return -1; + return 0; } return node->height; +} + +// non-member(s) +// max returns the greater of two integers. +int max(int a, int b) { + if (a > b) { + return a; + } + return b; } \ No newline at end of file diff --git a/labs/lab05/code/postlab/AVLTree.h b/labs/lab05/code/postlab/AVLTree.h index 28a05b816..e46934ef2 100644 --- a/labs/lab05/code/postlab/AVLTree.h +++ b/labs/lab05/code/postlab/AVLTree.h @@ -1,21 +1,13 @@ +// Feel free to edit this file and add functions as necessary + #ifndef AVL_H #define AVL_H +#include "AVLNode.h" #include using namespace std; -class AVLNode { - AVLNode(); - - string value; - AVLNode* left; - AVLNode* right; - int height; - - friend class AVLTree; -}; - class AVLTree { public: AVLTree(); @@ -49,17 +41,18 @@ class AVLTree { AVLNode* rotateRight(AVLNode*& n); // private helper for remove to allow recursion over different nodes. returns - // an AVLNode* that is assigned to the original node. - AVLNode* remove(AVLNode*& n, const string& x); + // an true if the node is removed; false otherwise + bool remove(AVLNode*& n, const string& x); // min finds the string with the smallest value in a subtree. string min(AVLNode* node) const; // height returns the value of the height field in a node. If the node is - // null, it returns -1. + // null, it returns 0. int height(AVLNode* node) const; // Any other methods you need... }; +// non-member(s) // max returns the greater of two integers. int max(int a, int b); diff --git a/labs/lab05/code/postlab/BinaryNode.cpp b/labs/lab05/code/postlab/BinaryNode.cpp new file mode 100644 index 000000000..0cc4a1489 --- /dev/null +++ b/labs/lab05/code/postlab/BinaryNode.cpp @@ -0,0 +1,21 @@ +#include "BinaryNode.h" +#include + +using namespace std; + +BinaryNode::BinaryNode() +{ + value = ""; + left = NULL; + right = NULL; +} + +BinaryNode~BinaryNode() +{ + delete left; + delete right; + + // to avoid crash on double deletes + left = NULL; + right = NULL; +} \ No newline at end of file diff --git a/labs/lab05/code/postlab/BinaryNode.h b/labs/lab05/code/postlab/BinaryNode.h new file mode 100644 index 000000000..3aca23fe2 --- /dev/null +++ b/labs/lab05/code/postlab/BinaryNode.h @@ -0,0 +1,17 @@ +#ifndef BINARY_NODE +#define BINARY_NODE + +#include + +class BinaryNode { + BinaryNode(); + ~BinaryNode(); + + std::string value; + BinaryNode* left; + BinaryNode* right; + + friend class BinarySearchTree; +}; + +#endif //BINARY_NODE \ No newline at end of file diff --git a/labs/lab05/code/postlab/BinarySearchTree.h b/labs/lab05/code/postlab/BinarySearchTree.h index a443fd352..091516977 100644 --- a/labs/lab05/code/postlab/BinarySearchTree.h +++ b/labs/lab05/code/postlab/BinarySearchTree.h @@ -1,15 +1,9 @@ +// Feel free to edit this file and add functions as necessary + #ifndef BST_H #define BST_H -class BinaryNode { - BinaryNode(); - - string value; - BinaryNode* left; - BinaryNode* right; - - friend class BinarySearchTree; -}; +#include "BinaryNode.h" class BinarySearchTree { public: From 5eade62915bd12487943b3e76c4afef19c14301a Mon Sep 17 00:00:00 2001 From: Zachary Danz Date: Thu, 1 Mar 2018 12:34:13 -0500 Subject: [PATCH 2/5] minor fixes to binary node h and cpp, including ='s override --- labs/lab05/code/postlab/BinaryNode.cpp | 13 ++++++++++++- labs/lab05/code/postlab/BinaryNode.h | 1 + 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/labs/lab05/code/postlab/BinaryNode.cpp b/labs/lab05/code/postlab/BinaryNode.cpp index 0cc4a1489..50825dfd4 100644 --- a/labs/lab05/code/postlab/BinaryNode.cpp +++ b/labs/lab05/code/postlab/BinaryNode.cpp @@ -10,7 +10,7 @@ BinaryNode::BinaryNode() right = NULL; } -BinaryNode~BinaryNode() +BinaryNode::~BinaryNode() { delete left; delete right; @@ -18,4 +18,15 @@ BinaryNode~BinaryNode() // to avoid crash on double deletes left = NULL; right = NULL; +} + +BinaryNode& BinaryNode::operator=(const BinaryNode& other) +{ + if (this != &other) + { + this->value = other.value; + this->left = other.left; + this->right = other.right; + } + return *this; } \ No newline at end of file diff --git a/labs/lab05/code/postlab/BinaryNode.h b/labs/lab05/code/postlab/BinaryNode.h index 3aca23fe2..c80afc594 100644 --- a/labs/lab05/code/postlab/BinaryNode.h +++ b/labs/lab05/code/postlab/BinaryNode.h @@ -6,6 +6,7 @@ class BinaryNode { BinaryNode(); ~BinaryNode(); + BinaryNode& operator=(const BinaryNode& other); std::string value; BinaryNode* left; From 267bbb4f21975b72a2fd9ce0fe15ff235b18c48d Mon Sep 17 00:00:00 2001 From: Zachary Danz Date: Thu, 1 Mar 2018 12:39:46 -0500 Subject: [PATCH 3/5] changes to index md and code zip to reflect updates --- labs/lab05/code.zip | Bin 14148 -> 160 bytes labs/lab05/index.md | 4 ++-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/labs/lab05/code.zip b/labs/lab05/code.zip index 7974814d54c5bd5af71a3e77bad1d32e60c804b5..282931dbe37d126c8f91e3f2ba8e645943c81949 100644 GIT binary patch literal 160 zcmWIWW@h1H0D*SyL?18%O0Y7>FeK-vr0R!;a56C0&7B^#(Q-yqX$3a}Bgj+{(jbnuvhhY>e8%Pl&5PAb?dk}{K06D@HrT_o{ literal 14148 zcma)D1yt4B)1^VAq`SMMyBjXu-Q6WEA>Ab)DIg#XN{ABD-QAs%(#;3*d=Gs3{@=Ze zT;Vu4t z1KL@q@j?zRD5G9q){IO@6sxfhC|`04ixf+3RaM^r z%6oBTPn7RUr#ZEMDZdfCoRhVY$VG!}s+X2#N;5m+F#}(dKg%w$LtUmff5fwPJXK+h zts1_QS5wu4qw^_6gbc~k!<3zLSJ`#`jW*)f_ZLOEgc$3J+B-+DJKds-tgZcoM++1s zge!9_{RpxFR4YX@WydQ@yBsy2rOF7vhSbr;4y@Uvh6<)c4%6v0jaa+XQ$Ni}LV`ZC z(k@8!(SdZS`Ram;qv!c-p|TEhMRSvl#W^Xeu!Ih2#3`LVu`EldEQ@>vuWvAr7*gAN zUZp`rVy*Q8{dS8W!DEmC$^%!!V4Du66hk5+jO8Ia?@7@U1OcWY@dGeLnHPC>1B5Q8 z_-qUfNYK%@zwx9p@|mBbi<5{rxk>Hoy8-c;hZoFBQZ8s*GbwZ_F_L34WvR)?+wZp;0MN^h(f2eez#jls6&jg8m3#0xZHl+QQ>|Y zQZF7;0rn>qY;7DIE%o&O_5cCXJrn+6(T0}FBgditx|Cm8QqkVXh}OW?_Kr{9qEYJc z!cjl`=&uN{ndC#LyHE*33>J7Q^f>@5uT6|RkaGLwhc=gyBiczVq)hUw?bL}tDJfGp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B;2de~V?HfPRW)?qTm!&#!en%mdhM{*c=V&wU8oKXCY&eeNDJJT&eO<>6!L z$J}iG1?BG%@{j*JxIgaSAwGO4@_4((D39%Wi1=42@@LqGbMMEL=fL^{?BA6CotY2E zVOS5`m*rE8^C!IjY2?FM4)!C^HGzyyy_y@>uB^?w@tuuXh?{Ar~B zhW^Hh%a-sTMe diff --git a/labs/lab05/index.md b/labs/lab05/index.md index b938f57ee..093c506c9 100644 --- a/labs/lab05/index.md +++ b/labs/lab05/index.md @@ -41,8 +41,8 @@ Procedure 1. For this lab, you will implement a Binary search tree, an AVL tree, and submit a brief lab report electronically via the submission system. 2. Your report must be in PDF format! See the [How to convert a file to PDF](../../docs/convert_to_pdf.html) page for details. -3. Files to download: [BinarySearchTree.h](code/postlab/BinarySearchTree.h.html) ([src](code/postlab/BinarySearchTree.h)), [AVLTree.h](code/postlab/AVLTree.h.html) ([src](code/postlab/AVLTree.h)), [AVLTree.cpp](code/postlab/AVLTree.cpp.html) ([src](code/postlab/AVLTree.cpp)), [TreePathTest.cpp](code/postlab/TreePathTest.cpp.html) ([src](code/postlab/TreePathTest.cpp)), [testfile1.txt](code/postlab/testfile1.txt), [testfile2.txt](code/postlab/testfile2.txt), [testfile3.txt](code/postlab/testfile3.txt). These files are contained in the postlab/ directory of the [code.zip](code.zip) file. -4. Files to submit: AVLTree.h, BinarySearchTree.h, TreePathTest.cpp, Makefile, any other files needed to make your code compile (files such as AVLTree.cpp, BinarySearchTree.cpp, etc...), analysis.pdf (see the post-lab section for formatting details) +3. Files to download: [BinaryNode.h](code/postlab/BinaryNode.h.html) ([src](code/postlab/BinaryNode.h)), [BinaryNode.cpp](code/postlab/BinaryNode.cpp.html) ([src](code/postlab/BinaryNode.cpp)), [BinarySearchTree.h](code/postlab/BinarySearchTree.h.html) ([src](code/postlab/BinarySearchTree.h)), [AVLNode.h](code/postlab/AVLNode.h.html) ([src](code/postlab/AVLNode.h)), [AVLNode.cpp](code/postlab/AVLNode.cpp.html) ([src](code/postlab/AVLNode.cpp)), [AVLTree.h](code/postlab/AVLNode.h.html), ([src](code/postlab/AVLTree.h)), [AVLTree.cpp](code/postlab/AVLTree.cpp.html) ([src](code/postlab/AVLTree.cpp)), [TreePathTest.cpp](code/postlab/TreePathTest.cpp.html) ([src](code/postlab/TreePathTest.cpp)), [testfile1.txt](code/postlab/testfile1.txt), [testfile2.txt](code/postlab/testfile2.txt), [testfile3.txt](code/postlab/testfile3.txt). These files are contained in the postlab/ directory of the [code.zip](code.zip) file. +4. Files to submit: AVLTree.h, BinarySearchTree.h, TreePathTest.cpp, Makefile, any other files needed to make your code compile (files such as AVLTree.cpp, BinarySearchTree.cpp, Node.h's and .cpp's, etc...), analysis.pdf (see the post-lab section for formatting details) ------------------------------------------------------------ From 23acb44b7ca44982c3b4bda4372f7f8a0cbd4ebe Mon Sep 17 00:00:00 2001 From: Zachary Danz Date: Mon, 12 Mar 2018 13:32:50 -0400 Subject: [PATCH 4/5] changes to remove so that balance works as expected, change comment for balance, added pretty postorder print to binarysearchtree and avltree, added binarysearchtree.cpp, default returns to all methods that require them for on-delivery compile --- labs/lab05/code.zip | Bin 160 -> 160 bytes labs/lab05/code/postlab/AVLNode.h | 2 +- labs/lab05/code/postlab/AVLTree.cpp | 50 +++++++++++++------ labs/lab05/code/postlab/AVLTree.h | 10 +++- labs/lab05/code/postlab/BinarySearchTree.cpp | 43 ++++++++++++++++ labs/lab05/code/postlab/BinarySearchTree.h | 9 ++++ 6 files changed, 97 insertions(+), 17 deletions(-) create mode 100644 labs/lab05/code/postlab/BinarySearchTree.cpp diff --git a/labs/lab05/code.zip b/labs/lab05/code.zip index 282931dbe37d126c8f91e3f2ba8e645943c81949..3e7e0a6017ee212c726c3f0696d8a2ddb11cb7b7 100644 GIT binary patch delta 13 UcmZ3$xPWnj4s-3!WfS!a0U=EV4*&oF delta 13 UcmZ3$xPWnj4)aFK858vj0Uyl-wEzGB diff --git a/labs/lab05/code/postlab/AVLNode.h b/labs/lab05/code/postlab/AVLNode.h index 25ae69e01..82e8369bb 100644 --- a/labs/lab05/code/postlab/AVLNode.h +++ b/labs/lab05/code/postlab/AVLNode.h @@ -11,7 +11,7 @@ class AVLNode { std::string value; AVLNode* left; AVLNode* right; - int depth; + int height; friend class AVLTree; }; diff --git a/labs/lab05/code/postlab/AVLTree.cpp b/labs/lab05/code/postlab/AVLTree.cpp index 69dd60884..6977c54ec 100644 --- a/labs/lab05/code/postlab/AVLTree.cpp +++ b/labs/lab05/code/postlab/AVLTree.cpp @@ -1,8 +1,9 @@ // Feel free to edit this file and add functions as necessary - #include "AVLTree.h" #include "AVLNode.h" #include +#include +#include //for setw in postorder using namespace std; @@ -12,34 +13,36 @@ AVLTree::AVLTree() { } AVLTree::~AVLTree() { } void AVLTree::insert(const string& x) { } -string AVLTree::pathTo(const string& x) const { } -bool AVLTree::find(const string& x) const { } -int AVLTree::numNodes() const { } +string AVLTree::pathTo(const string& x) const { return ""; } +bool AVLTree::find(const string& x) const { return false; } +int AVLTree::numNodes() const { return -1; } +// balance should balance only the single node it is given void AVLTree::balance(AVLNode*& n) { } -AVLNode* AVLTree::rotateLeft(AVLNode*& n) { } -AVLNode* AVLTree::rotateRight(AVLNode*& n) { } +AVLNode* AVLTree::rotateLeft(AVLNode*& n) { return NULL; } +AVLNode* AVLTree::rotateRight(AVLNode*& n) { return NULL; } /** The following are implemented for you: remove, max, min, and height; remove finds x's position in the tree and removes it, rebalancing as necessary. **/ -void AVLTree::remove(const string& x) { if(remove(root, x)) balance(root); } +void AVLTree::remove(const string& x) { remove(root, x); } /** private helper for remove to allow recursion over different nodes; returns an AVLNode* that is assigned to the original node. **/ bool AVLTree::remove(AVLNode*& current, const string& x) { + bool returnVal = false; // base-case for x not present in tree if (current == NULL) { - return false; + returnVal = false; } // recursively approach base case to left else if (x < current->value) { - return remove(current->left, x); + returnVal = remove(current->left, x); } // recursively approach base case to right else if (x > current->value) { - return remove(current->right, x); + returnVal = remove(current->right, x); } // base-case for x present in tree else @@ -49,7 +52,7 @@ bool AVLTree::remove(AVLNode*& current, const string& x) { { delete current; current = NULL; - return (current == NULL); // should be true + returnVal = (current == NULL); // should be true } // two children else if (current-> left != NULL && current->right != NULL) @@ -66,8 +69,8 @@ bool AVLTree::remove(AVLNode*& current, const string& x) { current->value = rLMost->value; // this should immediately reach either base-case present // with (above) no children or (below) one child, the right - // just one more recurse. - return remove(rLMost, rLMost->value); + // just log more recurse; runtime preserved. + returnVal = remove(current->right, rLMost->value); } // one child else @@ -80,9 +83,11 @@ bool AVLTree::remove(AVLNode*& current, const string& x) { current->height = heightTemp; delete child; child = NULL; - return (child == NULL); //should be true + returnVal = (child == NULL); //should be true } } + balance(current); + return returnVal; // recall that if this returns true, balance(root) will be called, fixing any inbalance } @@ -104,6 +109,23 @@ int AVLTree::height(AVLNode* node) const { return node->height; } +void AVLTree::print() +{ + postorder(root, 0); +} + +void AVLTree::postorder(AVLNode*& current, int indent) +{ + if(current != NULL) { + if(current->left != NULL) postorder(current->left, indent+4); + if(current->right != NULL) postorder(current->right, indent+4); + if (indent) { + std::cout << std::setw(indent) << ' '; + } + std::cout << current->value << std::endl; + } +} + // non-member(s) // max returns the greater of two integers. int max(int a, int b) { diff --git a/labs/lab05/code/postlab/AVLTree.h b/labs/lab05/code/postlab/AVLTree.h index e46934ef2..ec6a6f74e 100644 --- a/labs/lab05/code/postlab/AVLTree.h +++ b/labs/lab05/code/postlab/AVLTree.h @@ -28,12 +28,14 @@ class AVLTree { // numNodes returns the total number of nodes in the tree. int numNodes() const; + void print(); + private: // Declare a root node AVLNode* root; - // balance makes sure that the subtree with root n maintains the AVL tree - // property, namely that the balance factor of n is either -1, 0, or 1. + // balance should balance only the single node it is given + // that the balance factor of n is either -1, 0, or 1. void balance(AVLNode*& n); // rotateLeft performs a single rotation on node n with its left child. AVLNode* rotateLeft(AVLNode*& n); @@ -49,6 +51,10 @@ class AVLTree { // null, it returns 0. int height(AVLNode* node) const; + // prints a subtree + // call on root for postorder of full tree + void postorder(AVLNode* ¤t, int indent); + // Any other methods you need... }; diff --git a/labs/lab05/code/postlab/BinarySearchTree.cpp b/labs/lab05/code/postlab/BinarySearchTree.cpp new file mode 100644 index 000000000..39a20da3e --- /dev/null +++ b/labs/lab05/code/postlab/BinarySearchTree.cpp @@ -0,0 +1,43 @@ +// Feel free to edit this file and add functions as necessary +#include "BinaryNode.h" +#include "BinarySearchTree.h" +#include +#include +#include //for setw in postorder + +using namespace std; + +BinarySearchTree::BinarySearchTree() {} +BinarySearchTree::~BinarySearchTree() {} + +// insert finds a position for x in the tree and places it there. +void BinarySearchTree::insert(const string& x) {} +// remove finds x's position in the tree and removes it. +void BinarySearchTree::remove(const string& x) {} + +// pathTo finds x in the tree and returns a string representing the path it +// took to get there. +string BinarySearchTree::pathTo(const string& x) const { return ""; } +// find determines whether or not x exists in the tree. +bool BinarySearchTree::find(const string& x) const { return false; } +// numNodes returns the total number of nodes in the tree. +int BinarySearchTree::numNodes() const { return -1; } + +void BinarySearchTree::print() +{ + postorder(root, 0); +} + +// prints a subtree +// call on root for postorder of full tree +void BinarySearchTree::postorder(BinaryNode* ¤t, int indent) +{ + if(current != NULL) { + if(current->left) postorder(current->left, indent+4); + if(current->right) postorder(current->right, indent+4); + if (indent) { + std::cout << std::setw(indent) << ' '; + } + std::cout << current->value << std::endl; + } +} \ No newline at end of file diff --git a/labs/lab05/code/postlab/BinarySearchTree.h b/labs/lab05/code/postlab/BinarySearchTree.h index 091516977..4920ec786 100644 --- a/labs/lab05/code/postlab/BinarySearchTree.h +++ b/labs/lab05/code/postlab/BinarySearchTree.h @@ -5,6 +5,8 @@ #include "BinaryNode.h" +using namespace std; + class BinarySearchTree { public: BinarySearchTree(); @@ -22,12 +24,19 @@ class BinarySearchTree { bool find(const string& x) const; // numNodes returns the total number of nodes in the tree. int numNodes() const; + + void print(); private: // Declare a root node BinaryNode* root; + // prints a subtree + // call on root for postorder of full tree + void postorder(BinaryNode* ¤t, int indent); + // Any other methods you need... }; + #endif \ No newline at end of file From 3a5b503c6420919c6257489c443147cc88fb4645 Mon Sep 17 00:00:00 2001 From: Zachary Danz Date: Mon, 12 Mar 2018 13:36:28 -0400 Subject: [PATCH 5/5] left behind change to md --- labs/lab05/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/labs/lab05/index.md b/labs/lab05/index.md index 093c506c9..0f109edb9 100644 --- a/labs/lab05/index.md +++ b/labs/lab05/index.md @@ -41,7 +41,7 @@ Procedure 1. For this lab, you will implement a Binary search tree, an AVL tree, and submit a brief lab report electronically via the submission system. 2. Your report must be in PDF format! See the [How to convert a file to PDF](../../docs/convert_to_pdf.html) page for details. -3. Files to download: [BinaryNode.h](code/postlab/BinaryNode.h.html) ([src](code/postlab/BinaryNode.h)), [BinaryNode.cpp](code/postlab/BinaryNode.cpp.html) ([src](code/postlab/BinaryNode.cpp)), [BinarySearchTree.h](code/postlab/BinarySearchTree.h.html) ([src](code/postlab/BinarySearchTree.h)), [AVLNode.h](code/postlab/AVLNode.h.html) ([src](code/postlab/AVLNode.h)), [AVLNode.cpp](code/postlab/AVLNode.cpp.html) ([src](code/postlab/AVLNode.cpp)), [AVLTree.h](code/postlab/AVLNode.h.html), ([src](code/postlab/AVLTree.h)), [AVLTree.cpp](code/postlab/AVLTree.cpp.html) ([src](code/postlab/AVLTree.cpp)), [TreePathTest.cpp](code/postlab/TreePathTest.cpp.html) ([src](code/postlab/TreePathTest.cpp)), [testfile1.txt](code/postlab/testfile1.txt), [testfile2.txt](code/postlab/testfile2.txt), [testfile3.txt](code/postlab/testfile3.txt). These files are contained in the postlab/ directory of the [code.zip](code.zip) file. +3. Files to download: [BinaryNode.h](code/postlab/BinaryNode.h.html) ([src](code/postlab/BinaryNode.h)), [BinaryNode.cpp](code/postlab/BinaryNode.cpp.html) ([src](code/postlab/BinaryNode.cpp)), [BinarySearchTree.h](code/postlab/BinarySearchTree.h.html) ([src](code/postlab/BinarySearchTree.h)), [BinarySearchTree.cpp](code/postlab/BinarySearchTree.cpp.html) ([src](code/postlab/BinarySearchTree.cpp)), [AVLNode.h](code/postlab/AVLNode.h.html) ([src](code/postlab/AVLNode.h)), [AVLNode.cpp](code/postlab/AVLNode.cpp.html) ([src](code/postlab/AVLNode.cpp)), [AVLTree.h](code/postlab/AVLNode.h.html), ([src](code/postlab/AVLTree.h)), [AVLTree.cpp](code/postlab/AVLTree.cpp.html) ([src](code/postlab/AVLTree.cpp)), [TreePathTest.cpp](code/postlab/TreePathTest.cpp.html) ([src](code/postlab/TreePathTest.cpp)), [testfile1.txt](code/postlab/testfile1.txt), [testfile2.txt](code/postlab/testfile2.txt), [testfile3.txt](code/postlab/testfile3.txt). These files are contained in the postlab/ directory of the [code.zip](code.zip) file. 4. Files to submit: AVLTree.h, BinarySearchTree.h, TreePathTest.cpp, Makefile, any other files needed to make your code compile (files such as AVLTree.cpp, BinarySearchTree.cpp, Node.h's and .cpp's, etc...), analysis.pdf (see the post-lab section for formatting details) ------------------------------------------------------------