Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Enhance the provided Treap class to incorporate additional functionalities that will help in understanding the use of augmented data structures in tree - based algorithms
Enhance the provided Treap class to incorporate additional functionalities that will help in
understanding the use of augmented data structures in treebased 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 include node and
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 funcon to test each additional functionality.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started