Using the following c++ header file near the bottom for context, fill in the "TODO" commented parts of the following function to finish the function implementation for the following insertVertex function: FUNCTION: // PURPOSE: Does IN order traversal from V recursively// PARAM: V is te pointer to the vertex to visit right nowvoid BST::InOrderTraversal(Vertex *V){  if (V != NULL)  {    // TODO  traverse left sub-tree of V recursively    // TODO  display V's element, height and balance and do endl;    // TODO traverse right sub-tree of V recursively  }}--------------------------------------------------------------------------------------------- HEADER FILE: // tree element type is int for nowtypedef int el_t;   // el_t is hidden from the client // definition of what a Vertex is - also hidden from the clientstruct Vertex{  Vertex *up;  // points to the parent node  Vertex *left;  el_t  elem;  Vertex *right;  int height;  int balance;}; // this is set up to be inherited by another classclass BST {public:  BST();  // intializes Root  ~BST();  // destructor calls dtraverse to destroy the dynamic tree   // PURPOSE: these will show the vertices in IN order  // TO CALL: No parameter  but provide a pointer to  //          the root vertex in calling INorderTraversal  void Display();  void InOrderTraversal(Vertex*); // recursive   // PURPOSE: these will search in PRE order - same as Depth First  // TO CALL: provide the element to search for; provide a pointer to  //          the root vertex in calling PREorderSearch  bool Search(el_t);  bool PreOrderSearch(Vertex*, el_t); // recursive

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter15: Recursion
Section: Chapter Questions
Problem 8SA
icon
Related questions
Question

Using the following c++ header file near the bottom for context, fill in the "TODO" commented parts of the following function to finish the function implementation for the following insertVertex function:

FUNCTION: 
// PURPOSE: Does IN order traversal from V recursively
// PARAM: V is te pointer to the vertex to visit right now
void BST::InOrderTraversal(Vertex *V)
{
  if (V != NULL)
  {
    // TODO  traverse left sub-tree of V recursively
    // TODO  display V's element, height and balance and do endl;
    // TODO traverse right sub-tree of V recursively
  }
}---------------------------------------------------------------------------------------------

HEADER FILE:


// tree element type is int for now
typedef int el_t;   // el_t is hidden from the client


// definition of what a Vertex is - also hidden from the client
struct Vertex
{
  Vertex *up;  // points to the parent node
  Vertex *left;
  el_t  elem;
  Vertex *right;
  int height;
  int balance;
};


// this is set up to be inherited by another class
class BST {
public:
  BST();  // intializes Root
  ~BST();  // destructor calls dtraverse to destroy the dynamic tree


  // PURPOSE: these will show the vertices in IN order
  // TO CALL: No parameter  but provide a pointer to
  //          the root vertex in calling INorderTraversal
  void Display();
  void InOrderTraversal(Vertex*); // recursive


  // PURPOSE: these will search in PRE order - same as Depth First
  // TO CALL: provide the element to search for; provide a pointer to
  //          the root vertex in calling PREorderSearch
  bool Search(el_t);
  bool PreOrderSearch(Vertex*, el_t); // recursive

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Functions
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning