Question: Note: All programs must use the appropriate C + + features. Objective: Enhance the provided Treap class to incorporate additional functionalities that will help in

Note: All programs must use the appropriate C++ features.
Objective:
Enhance the provided Treap class to incorporate additional functionalities that will help in
understanding the use of augmented data structures in tree-based algorithms and OOP
principles.
Tasks:
You are provided with a basic implementation of a Treap class that includes methods for
insertion, deletion, search, etc. Your task is to modify the Treap class so that
each node can keep track of the sum of keys of nodes under this node, including
itself. Then, print the sum for each node.
For example, nodes under node 20 include node 10,22,5 and 12.
each node can keep track of the count of all nodes under this node, including itself.
Then, print the count for each node.
Add a new function to the Treap class to return the count of nodes without children
(leaf nodes). Then, print this count.
Add a new function to the Treap class to return the count of nodes with only one
child. Then, print this count.
Add a new function to the Treap class to return the count of nodes with two
children. Then, print this count.
Input & Output:
You need to provide test cases in the main function to test each additional functionality.
Submit:
1, all C++ source code
2, week10.txt: a txt file contains all the source code.
3, week10.docx or week10.pdf, this document should include
the screenshot of printing the treap, with key and priority
the screenshots for each of these five tasks.
 Note: All programs must use the appropriate C++ features. Objective: Enhance

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!