Respuesta :

The method that computes and prints the element of p followed by the height of p's subtree for each position p/node of a tree t and include this method in the binary tree class is given below

What is an element?

A single component that is a part of a larger group is called an element. In computer programming, for instance, an array may contain various elements (indexed), each of which may be stored and used independently.

For instance, the names array in the Perl code below has five elements (names), and it uses a foreach to introduce itself to each name.

#include <bits/stdc++.h>

using namespace std;

/* A binary tree node has data, pointer to left child

and a pointer to right child */

class node {

public:

  int data;

  node* left;

  node* right;

};

/* Compute the "maxDepth" of a tree -- the number of

  nodes along the longest path from the root node

  down to the farthest leaf node.*/

int maxDepth(node* node)

{

  if (node == NULL)

      return 0;

  else {

      /* compute the depth of each subtree */

      int lDepth = maxDepth(node->left);

      int rDepth = maxDepth(node->right);

      /* use the larger one */

      if (lDepth > rDepth)

          return (lDepth + 1);

      else

          return (rDepth + 1);

  }

}

Learn more about element

https://brainly.com/question/28813109

#SPJ4