201 {
+
+
+
+
+
+
+
+
+
+
+
212
+
+
214 2, 5, 4, 9};
+
+
216 11, 5, 9, 4};
+
+
218 4, 9, 5, 2};
+
+
220 result_inorder;
+
221
+
+
223 result_preorder;
+
224
+
+
226 result_postorder;
+
227
+
228
+
+
230
+
231
+
232
+
233 result_inorder = obj1.inorder(root);
+
234 std::cout <<
"Testcase #1: Inorder Traversal...";
+
235 for (auto i = 0; i < size; ++i) {
+
236 assert(actual_result_inorder[i] == result_inorder[i]);
+
237 }
+
+
239
+
240
+
241
+
242 result_preorder = obj1.
preorder(root);
+
243 std::cout <<
"Testcase #1: Preorder Traversal...";
+
244 for (auto i = 0; i < size; ++i) {
+
245 assert(actual_result_preorder[i] == result_preorder[i]);
+
246 }
+
+
248
+
249
+
250
+
+
252 std::cout <<
"Testcase #1: Postorder Traversal...";
+
253 for (auto i = 0; i < size; ++i) {
+
254 assert(actual_result_postorder[i] == result_postorder[i]);
+
255 }
+
+
257
+
+
259 deleteAll(root);
+
260}
-
BT used to make the entire structure of the binary tree and the functions associated with the binary ...
Definition recursive_tree_traversal.cpp:87
-
Node * createNewNode(uint64_t)
will allocate the memory for a node and, along the data and return the node.
Definition recursive_tree_traversal.cpp:116
-
std::vector< uint64_t > postorder(Node *)
postorder function that will perform the postorder traversal recursively, and return the result vecto...
Definition recursive_tree_traversal.cpp:170
-
std::vector< uint64_t > preorder(Node *)
preorder function that will perform the preorder traversal recursively, and return the resultant vect...
Definition recursive_tree_traversal.cpp:150
+
BT used to make the entire structure of the binary tree and the functions associated with the binary ...
Definition recursive_tree_traversal.cpp:88
+
std::vector< std::uint64_t > preorder(Node *)
preorder function that will perform the preorder traversal recursively, and return the resultant vect...
Definition recursive_tree_traversal.cpp:152
+
std::vector< std::uint64_t > postorder(Node *)
postorder function that will perform the postorder traversal recursively, and return the result vecto...
Definition recursive_tree_traversal.cpp:172
+
Node * createNewNode(std::uint64_t)
will allocate the memory for a node and, along the data and return the node.
Definition recursive_tree_traversal.cpp:118
-
The structure to hold Nodes of the tree.
Definition recursive_tree_traversal.cpp:78
+
+
The structure to hold Nodes of the tree.
Definition recursive_tree_traversal.cpp:79