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 findMax function: FUNCTION:  // PURPOSE: Finds the Maximum element in the left sub-tree of V // and also deletes that vertex el_t BST::findMax(Vertex *V) {   Vertex *Parent = V;   V = V->left;         // start with the left child of V   while (/*TODO*/) {// TODO while the right child of V is still available     //TODO update Parent and V to go to the right   }   // reached NULL Right  -- V now has the MAX element   el_t X = V->elem;   cout << "...Max is " << X << endl;   remove(V, Parent);    // remove the MAX vertex   return X;             // return the MAX element }// end of FindMax     --------------------------------------------------------------------------------------------- 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

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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 findMax function:

FUNCTION: 

// PURPOSE: Finds the Maximum element in the left sub-tree of V
// and also deletes that vertex
el_t BST::findMax(Vertex *V) {
  Vertex *Parent = V;
  V = V->left;         // start with the left child of V

  while (/*TODO*/) {// TODO while the right child of V is still available
    //TODO update Parent and V to go to the right
  }
  // reached NULL Right  -- V now has the MAX element
  el_t X = V->elem;
  cout << "...Max is " << X << endl;
  remove(V, Parent);    // remove the MAX vertex
  return X;             // return the MAX element

}// end of FindMax
 
 
---------------------------------------------------------------------------------------------

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

AI-Generated Solution
AI-generated content may present inaccurate or offensive content that does not represent bartleby’s views.
steps

Unlock instant AI solutions

Tap the button
to generate a solution

Knowledge Booster
Linked List Representation
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
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education