Question
How to add a function pointer to Traversals in a Binary Search Tree in C++. The BST takes in Date Class Objects. The Class is
How to add a function pointer to Traversals in a Binary Search Tree in C++.
The BST takes in Date Class Objects. The Class is made of 3 ints. Days Months and Years. I have made attempts but every time something goes wrong with the syntax or I didn't add something correctly and I can figure out what was done wrong.
I have a Main program that opens a txt file and reads it and inputs into the BST struct thing below. I delete much and of the tree but left the inorder travesals. I should be able to adapt it to the other parts later.
template
struct Node
{
ElemTypedata;
struct Node
struct Node
Node(){
left = nullptr;
right = nullptr;
}
};
template
class BST
{
public:
BST(); /// Default Constructor
void postorder();
///Traversal Post Order
void preorder();
///Traversal PreOrder
void inorder ();
///Traversal InOrder
private:
void inorder(Node
};
template
void BST
{
std::cout << "------ Inorder-----" << std::endl;
inorder(root);
std::cout << std::endl;
}
template
void BST
{
if(R != NULL)
{
inorder(R->left);
std::cout<
inorder(R->right);
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started