C++ PROGRAMMING Topic: Binary Search Trees Explain the c++ code below.: SEE ATTACHED PHOTO FOR THE PROBLEM INSTRUCTIONS  It doesn't have to be long, as long as you explain what the important parts of the code do. (The code is already implemented and correct, only the explanation needed)

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

C++ PROGRAMMING
Topic: Binary Search Trees

Explain the c++ code below.: SEE ATTACHED PHOTO FOR THE PROBLEM INSTRUCTIONS 

It doesn't have to be long, as long as you explain what the important parts of the code do. (The code is already implemented and correct, only the explanation needed) 
 
 
ADDITIONAL METHODS: Complete some of the methods in addition to the bare minimum
methods
•int childCount(node* p): Returns O if the position p has no children, -1 if p has only a left
child, 1 if p has only a right child, and 2 if p has two children.
• int set(node* p, int e): Replaces the element stored at position p with element e, and
returns the previously stored element.
•node* addSibling(node* p, int e): Creates a child of the parent of position p to make the
node a sibling of p and returns the position of the new node; an error occurs if p already has
a sibling or p has no parent.
•void clear(): Clears and frees up all of the nodes in the tree. This should be done
recursively where you can call a helper method that is recursive. You can only decrement the
value of your size (i.e. size--) and not directly set it to some other value (e.g. size=0,
size=size-size) in your code that is used by this method.
•void attach(node* p, BTree* T1, BTree* T2): Attaches the internal structure of trees T1 and
T2 as the respective left and right subtrees of leaf position p and optionally resets T1 and T2
to empty trees; an error condition occurs if p is not a leaf.
•int remove(node* p): Removes the node at position p, replacing it with its child (if any), and
returns the element that had been stored at p. An error occurs if p has two children and this
is the case since the tree is not ordered.
Transcribed Image Text:ADDITIONAL METHODS: Complete some of the methods in addition to the bare minimum methods •int childCount(node* p): Returns O if the position p has no children, -1 if p has only a left child, 1 if p has only a right child, and 2 if p has two children. • int set(node* p, int e): Replaces the element stored at position p with element e, and returns the previously stored element. •node* addSibling(node* p, int e): Creates a child of the parent of position p to make the node a sibling of p and returns the position of the new node; an error occurs if p already has a sibling or p has no parent. •void clear(): Clears and frees up all of the nodes in the tree. This should be done recursively where you can call a helper method that is recursive. You can only decrement the value of your size (i.e. size--) and not directly set it to some other value (e.g. size=0, size=size-size) in your code that is used by this method. •void attach(node* p, BTree* T1, BTree* T2): Attaches the internal structure of trees T1 and T2 as the respective left and right subtrees of leaf position p and optionally resets T1 and T2 to empty trees; an error condition occurs if p is not a leaf. •int remove(node* p): Removes the node at position p, replacing it with its child (if any), and returns the element that had been stored at p. An error occurs if p has two children and this is the case since the tree is not ordered.
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY