Question: I code level order for BST. Can anyone help this for bottom level order? void printLevelOrderHelper(Node *root) { queue q; if (root == NULL) return;
I code level order for BST.
Can anyone help this for bottom level order?
void printLevelOrderHelper(Node
queue
if (root == NULL)
return; //empty
// Create an empty queue
// Enqueue Root and initialize height
q.push(root);
while (q.empty() == false)
{
// Print front of queue and remove it from queue
Node
cout << root->value << " ";
q.pop();
/* Enqueue left child */
if (root->left != NULL)
q.push(root->left);
/*Enqueue right child */
if (root->right != NULL)
q.push(root->right);
}
out << endl;
}
vector
vector
// need to build bottomlevelorder here
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
