Question

In: Computer Science

Hi. Please could I get a complete answer to the question below using c++ and codeblocks...

Hi. Please could I get a complete answer to the question below using c++ and codeblocks

Add a recursive member function to bSearchTreeType that returns the depth of a given node whose info member contains a specific value, and returns -1 if the node is not in the tree. For example, tree in figure 11-8 on page 622 of Malik,z the depth of 40 is 4, the depth of node 50 is 1 etc.
Use the following header:   
template<class elemType>
int bSearchTreeType<elemType>:: int nodeLevel( const elemType & value

Thank you

Solutions

Expert Solution

/* We are not allowed to see book */

/* Below down is working function based on given information */

template<class elemType>

int nodelevel(const elemType & value)

{

    queue<node<elemType>*> q;

    int level = 1;

    q.push(root);

    // extra NULL is pushed to keep track

    // of all the nodes to be pushed before

    // level is incremented by 1

    q.push(NULL);

    while (!q.empty()) {

        node<elemType>* temp = q.front();

        q.pop();

        if (temp == NULL) {

            if (q.front() != NULL) {

                q.push(NULL);

            }

            level += 1;

        } else {

            if (temp->value == value) {

                return level;

            }

            if (temp->left) {

                q.push(temp->left);

            }

            if (temp->right) {

                q.push(temp->right);

            }

        }

    }

    return -1;

}


Related Solutions

Hi. Please could you assist me with the question below. I found the same question on...
Hi. Please could you assist me with the question below. I found the same question on the Chegg website, unfortunately, the answer given does not make use of the driver function which is required by the question. Please could you provide me with the full code for this question, including the main function using c++ and codeblocks. The standard recursive version of the Fibonacci function (explained in Malik pg. 379) is extremely inefficient due to identical calls being repeated. Consider...
I was wondering if I could get a step by step process to answer this question?
I was wondering if I could get a step by step process to answer this question?
Dear All Could you please answer the below question. I would expect a long answer to...
Dear All Could you please answer the below question. I would expect a long answer to may consist of 1500 words. "It has been argued in the finance literature that a great majority of mergers lead to value destruction. Citing empirical evidence, discuss whether you agree or disagree with this statment". Thank you!
I am stumped on these problems and homework question, please could I get the answers to...
I am stumped on these problems and homework question, please could I get the answers to the questions below from an expert. Thank you 5). Suppose that two population proportions are being compared to test weather there is any difference between them. Assume that the test statistic has been calculated to be z= 2.21. Find the p-value for this situation?   a). p-value = 0.4864 b). p-value = 0.0272 c). p-value = 0.9728 d). p-value = 0.0136. 8). If you are...
Please if you are able to answer the question below: Write C++ program using native C++...
Please if you are able to answer the question below: Write C++ program using native C++ (you can use STL)  that produces Huffman code for a string of text entered by the user.  Must accept all ASCII characters.  Pleas explain how you got frequencies of characters, how you sorted them, how you got codes.
Business Analytics Could I get the answer on a downloadable excel sheet please? if i cannot...
Business Analytics Could I get the answer on a downloadable excel sheet please? if i cannot get the downloadable file here on chegg: my email is [email protected] i can paypal $10 for the answer. Market Insights Co. (MIC) is a full-service market research company. MIC is being hired to interview registered voters in a district to gain insight into their opinions about certain issues. Each voter is to be interviewed in person. The costs of interviewing different types of voters...
Please answer the ENTIRE question below using complete sentences. A.What is the test statistic and how...
Please answer the ENTIRE question below using complete sentences. A.What is the test statistic and how do you find it? B. What are the conditions for using the standard deviation formula when working with a sampling distribution of proportions? C. What are the conditions for using the Normal approximation for a sampling distribution of proportions? D. Describe the Central Limit Theorem. E. How does increasing the sample size of a random sample affect the bias of a survey or poll?...
***I understand this question has already been asked, but could I possibly get a new answer?...
***I understand this question has already been asked, but could I possibly get a new answer? I am trying to study a variety of companies and answers so I will be more prepared for whatever is on the test.*** DoorDash as the company. 1. Select a company that has undergone an initial public offering within the last five years and obtain the prospectus (these are usually available on the company’s website, EDGAR for companies listed on the U. S. stock...
***I understand this question has already been asked, but could I possibly get a new answer?...
***I understand this question has already been asked, but could I possibly get a new answer? I am trying to study a variety of companies and answers so I will be more prepared for whatever is on the test.*** DoorDash as the company. 1. Select a company that has undergone an initial public offering within the last five years and obtain the prospectus (these are usually available on the company’s website, EDGAR for companies listed on the U. S. stock...
Hi I was wondering if I could get an explanation on how race, ethnic groups, multiracial...
Hi I was wondering if I could get an explanation on how race, ethnic groups, multiracial people, minority groups, dominanat groups, prejudice, discrimination and racisism all relate to one another?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT