BT used to make the entire structure of the binary tree and the functions associated with the binary tree.
More...
|
Node * | createNewNode (uint64_t) |
| will allocate the memory for a node and, along the data and return the node. More...
|
|
std::vector< uint64_t > | inorder (Node *) |
|
std::vector< uint64_t > | preorder (Node *) |
| preorder function that will perform the preorder traversal recursively, and return the resultant vector that contain the preorder traversal of a tree. More...
|
|
std::vector< uint64_t > | postorder (Node *) |
| postorder function that will perform the postorder traversal recursively, and return the result vector that contain the postorder traversal of a tree. More...
|
|
BT used to make the entire structure of the binary tree and the functions associated with the binary tree.
◆ createNewNode()
Node * others::recursive_tree_traversals::BT::createNewNode |
( |
uint64_t |
data | ) |
|
will allocate the memory for a node and, along the data and return the node.
- Parameters
-
data | value that a particular node will contain. |
- Returns
- pointer to the newly created node with assigned data.
116 {
121}
int data[MAX]
test data
Definition: hash_search.cpp:24
Definition: linkedlist_implentation_usingarray.cpp:14
Definition: avltree.cpp:13
◆ inorder()
std::vector< uint64_t > others::recursive_tree_traversals::BT::inorder |
( |
Node * |
root | ) |
|
130 {
131 if (root == nullptr) {
132 return {};
133 }
134
135 inorder(root->left);
136 BT::inorder_result.push_back(
138 inorder(root->right);
139
140 return inorder_result;
141}
◆ postorder()
std::vector< uint64_t > others::recursive_tree_traversals::BT::postorder |
( |
Node * |
root | ) |
|
postorder function that will perform the postorder traversal recursively, and return the result vector that contain the postorder traversal of a tree.
- Parameters
-
root | head/root node of a tree |
- Returns
- result that is containing the postorder traversal of a tree
170 {
171 if (root == nullptr) {
172 return {};
173 }
174
177 BT::postorder_result.push_back(
179
180 return postorder_result;
181}
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
◆ preorder()
std::vector< uint64_t > others::recursive_tree_traversals::BT::preorder |
( |
Node * |
root | ) |
|
preorder function that will perform the preorder traversal recursively, and return the resultant vector that contain the preorder traversal of a tree.
- Parameters
-
root | head/root node of a tree |
- Returns
- result that is containing the preorder traversal of a tree
150 {
151 if (root == nullptr) {
152 return {};
153 }
154
155 BT::preorder_result.push_back(
159
160 return preorder_result;
161}
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
The documentation for this class was generated from the following file: