Question
I'm receiving three errors on c++ code>. How do I fix? error: variable or field '_print_tree' declared void 33 | void _print_tree(Node *current) { error:
I'm receiving three errors on c++ code>. How do I fix?
error: variable or field '_print_tree' declared void
33 | void _print_tree(Node *current) {
error: 'Node' was not declared in this scope
33 | void _print_tree(Node *current) {
error: 'current' was not declared in this scope
33 | void _print_tree(Node *current) {
-------------------------------------------------------------------------------------
#include
using namespace std;
int nodeLevel(int value) {
if (root == NULL) {
return -1;
} else {
return _nodeLevel(value, root, 0);
}
}
int _nodeLevel(int value, Node *current, int level) {
if (current == NULL) {
return -1;
} else if (value == current->data) {
return level;
} else if (value < current->data) {
return _nodeLevel(value, current->left, level+1);
} else {
return _nodeLevel(value, current->right, level+1);
}
}
def print_tree() {
if (root == NULL) {
return;
} else {
_print_tree(root);
}
}
void _print_tree(Node *current) {
if (current == NULL) {
return;
} else {
_print_tree(current->left);
cout << current->data << endl;
_print_tree(current->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