Repository: TheAlgorithms/C-Plus-Plus
File: others/recursive_tree_traversal.cpp (C++)

Code before:
 * @namespace interpolation_search
 * @brief Functions for the Recursive version of Inorder, Preorder, and
 * Postorder [Traversal of the
 * Tree](https://en.wikipedia.org/wiki/Tree_traversal) algorithm implementation
 */
namespace recursive_tree_traversals {

/**
 * @brief The structure to hold Nodes of the tree.
 * @param data Value that will be stored in the node.
 * @param left follow up left subtree.
 * @param right follow up right subtree.
 */
struct Node {
    uint64_t data = 0;     ///< The value/key of the node.
    struct Node *left{};   ///< struct pointer to left subtree.
    struct Node *right{};  ///< struct pointer to right subtree.
};
/**
 * @brief BT used to make the entire structure of the binary tree and the
 * functions associated with the binary tree
 */
class BT {
 public:
    std::vector<uint64_t>
        inorder_result;  // vector to store the inorder traversal of the tree.
    std::vector<uint64_t>
        preorder_result;  // vector to store the preorder traversal of the tree.
    std::vector<uint64_t> postorder_result;  // vector to store the preorder
                                             // traversal of the tree.

    Node *createNewNode(
        uint64_t);  // function that will create new node for insertion.

    std::vector<uint64_t> inorder(
        Node *);  // function that takes root of the tree as an argument and
                  // returns its inorder traversal.
    std::vector<uint64_t> preorder(
        Node *);  // function that takes root of the tree as an argument and
                  // returns its preorder traversal.
    std::vector<uint64_t> postorder(
        Node *);  // function that takes root of the tree as an argument and
                  // returns its postorder traversal.
};

/**
 * @brief will allocate the memory for a node and, along the data and return the
 * node.
 * @param data value that a particular node will contain.
 * @return pointer to the newly created node with assigned data.
 */

Review comment (suggestion):
Is prefixing uint64_t necessary? Most of the algorithms don't do it. Thinking about it might become a future problem if we don't prefix it. Would love to hear your opinion on doing
```cpp
using std::uint64_t;
```

Code after:
/**
 * @namespace interpolation_search
 * @brief Functions for the Recursive version of Inorder, Preorder, and
 * Postorder [Traversal of the
 * Tree](https://en.wikipedia.org/wiki/Tree_traversal) algorithm implementation
 */
namespace recursive_tree_traversals {

/**
 * @brief The structure to hold Nodes of the tree.
 * @param data Value that will be stored in the node.
 * @param left follow up left subtree.
 * @param right follow up right subtree.
 */
struct Node {
    std::uint64_t data = 0;  ///< The value/key of the node.
    struct Node *left{};     ///< struct pointer to left subtree.
    struct Node *right{};    ///< struct pointer to right subtree.
};
/**
 * @brief BT used to make the entire structure of the binary tree and the
 * functions associated with the binary tree
 */
class BT {
 public:
    std::vector<std::uint64_t>
        inorder_result;  // vector to store the inorder traversal of the tree.
    std::vector<std::uint64_t>
        preorder_result;  // vector to store the preorder traversal of the tree.
    std::vector<std::uint64_t>
        postorder_result;  // vector to store the preorder
                           // traversal of the tree.

    Node *createNewNode(
        std::uint64_t);  // function that will create new node for insertion.

    std::vector<std::uint64_t> inorder(
        Node *);  // function that takes root of the tree as an argument and
                  // returns its inorder traversal.
    std::vector<std::uint64_t> preorder(
        Node *);  // function that takes root of the tree as an argument and
                  // returns its preorder traversal.
    std::vector<std::uint64_t> postorder(
        Node *);  // function that takes root of the tree as an argument and
                  // returns its postorder traversal.
};

/**
 * @brief will allocate the memory for a node and, along the data and return the
 * node.
 * @param data value that a particular node will contain.