Write some Software

I want you to add the following methods and modifications to the class treeclass. Do these methods as efficiently as possible.

First include a variable called size in every node of the tree. This value is set to the size of the tree rooted at that node. ie size = size of left sub tree + size of right sub tree + 1. Add a private method that returns the size of a tree given its pointer, ie sizeTree(Node * root) . You will use this method in determining rank() below. On all the methods below you should update size of all involved nodes during the operations. For example , when inserting a new node, update the size values of all nodes along the insert path appropriately so that the trees size variables are up to date after the insertion.

0. Add the delete(int x) method to the tree and its aux. This deletes the value x from the tree if it is present.

1. Add a method that returns the sum of the values in the tree. Make auxSum recursive ( int Sum() + int auxSum(node * root) )

2. Add a method called int rank(int x) that returns the number of nodes in the tree that have a value less than or equal to x. Include an aux if necessary. Do not traverse the entire tree to find the value. Use size info from the tree to determine this value efficiently. This is a little tricky so think before you program. HINT: you can look in the left sub trees root node to get info on how many nodes are over there. RankDiscussion is a case chart for rank.

3. Add a method called int range(int a,int b) that returns the number of nodes in the tree that have a value greater than a and less than or equal to b. Include an aux if necessary. Call rank to find the value to return.

4. Add a method called void ChangeKey(int key, int newvalue) that changes the node that has value key to newkey and modifies the tree appropriately so it is still a BST

Kemahiran: Pengaturcaraan C++

Tentang Majikan:
( 8 ulasan ) wichita falls, United States

ID Projek: #10098898

schrpa

Hi, I had to implement a TPC-C benchmark project last year where I used B and B+Trees. So this should not be a big problem for me and I am sure that I will finish it until tomorrow afternoon. Feel free to contact Lagi

\$20 USD dalam 10 hari
(0 Ulasan)
0.0

3 pekerja bebas membida secara purata \$27 untuk pekerjaan ini

it2051229

Hi, I have read the requirements and would like to do this project if given the opportunity. Let me know if you are interested so I can have further details. Thanks.

\$30 USD dalam sehari
(431 Ulasan)
6.7
whitedove81288

Hello, I'm a senior developer. I can finish this project . Thank you for reading my bid

\$30 USD dalam 2 hari
(0 Ulasan)
0.0