# Algorithms_in_C++: others::recursive_tree_traversals::BT Class Reference

Loading...
Searching...
No Matches
others::recursive_tree_traversals::BT Class Reference

BT used to make the entire structure of the binary tree and the functions associated with the binary tree. More...

Collaboration diagram for others::recursive_tree_traversals::BT:
[legend]

## Public Member Functions

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...

## Public Attributes

std::vector< uint64_t > | inorder_result
std::vector< uint64_t > | preorder_result
std::vector< uint64_t > | postorder_result

## Detailed Description

BT used to make the entire structure of the binary tree and the functions associated with the binary tree.

## Member Function Documentation

## 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.

{
Node *node = new Node();
node->data = data;
node->left = node->right = nullptr;
return node;
}
data
int data[MAX]
test data
Definition: hash_search.cpp:24
Node
Definition: linkedlist_implentation_usingarray.cpp:14
node
Definition: avltree.cpp:13

## inorder()

std::vector< uint64_t > others::recursive_tree_traversals::BT::inorder | ( | Node * | root | ) |

{
if (root == nullptr) { // return if the current node is empty
return {};
}
inorder(root->left); // Traverse the left subtree
BT::inorder_result.push_back(
root->data); // Display the data part of the root (or current node)
inorder(root->right); // Traverse the right subtree
return inorder_result;
}
std::vector::data
T data(T... args)

## 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

{
if (root == nullptr) { // if the current node is empty
return {};
}
postorder(root->left); // Traverse the left subtree
postorder(root->right); // Traverse the right subtree
BT::postorder_result.push_back(
root->data); // Display the data part of the root (or current node)
return postorder_result;
}
others::recursive_tree_traversals::BT::postorder
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
Here is the call graph for this function:

## 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

{
if (root == nullptr) { // if the current node is empty
return {};
}
BT::preorder_result.push_back(
root->data); // Display the data part of the root (or current node)
preorder(root->left); // Traverse the left subtree
preorder(root->right); // Traverse the right subtree
return preorder_result;
}
others::recursive_tree_traversals::BT::preorder
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
Here is the call graph for this function:

The documentation for this class was generated from the following file:

- others/recursive_tree_traversal.cpp