Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Complete Source.cpp Source.cpp programmar now. It is up to you to use recursion, or the normal while loop. :) bool search(int x, Node* root) {
Complete Source.cpp
Source.cpp
programmar now. It is up to you to use recursion, or the normal while loop. :) bool search(int x, Node* root) { // *************** TO DO***************** } b // This method returns the size of the tree given its root. // I know you are a professional programmar, but let's use recursion. Life becomes easier :D int size(Node* root) { // *************** TO DO***************** } // This method returns the hegihts of the tree given its root. // I know you are a professional programmar, but let's use recursion. Life becomes easier :D int height(Node* root) { // *************** TO DO***************** } // This method print out the tree in order given its root. // I know you are a professional programmar, but let's use recursion. It is more fun :D // The output should be -3 -1 1 2 3 4 5 6 8 9 11 12 13 16 20 void print_all(Node* root) { // *************** TO DO***************** } int main() { Node* root = create_tree_from_slides(); cout<< "Size of tree is 15; your output is: "<< size(root) <Node.h
#ifndef NODE_H #define NODE_H class Node { public: // We actually implement the constructor here, // in the header file (it's too little to "earn" a .cpp) Node(int n) { this->key = n; left = right = nullptr; } int key; Node* left; Node* right; }; #endif
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