1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
sergey [27]
3 years ago
10

Consider a binary search tree where each tree node v has a field v.sum which stores the sum of all the keys in the subtree roote

d at v.
(a) Modify the Insert operation (given below) to insert an element so that all the .sum fields of the tree are correct after applying the Insert operation. (Assume that all the .sum fields were correct before the Insert operation.) Your modified algorithm should take the same time as the original Insert operation. Explain your modification and give pseudo-code for the modified algorithm.

function Insert(T,z)

y <-- LocateParent(T,z)

z.parent <-- y

if (y = NIL) then T.root <-- z ;

else if (z.key< y.key) then y.left <-- z

else y.right <-- z

(b) Argue for the correctness of your algorithm. Explain why all the .sum fields are correct after running your modified Insert operation.

(c) Analyze the running time of your modified algorithm in terms of the size n and the height h of the binary search tree.
Computers and Technology
1 answer:
AVprozaik [17]3 years ago
6 0

Answer:

Each time you insert a new node, call the function to adjust the sum.

This method has to be called each time we insert new node to the tree since the sum at all the

parent nodes from the newly inserted node changes when we insert the node.

// toSumTree method will convert the tree into sum tree.

int toSumTree(struct node *node)

{

if(node == NULL)

return 0;

// Store the old value

int old_val = node->data;

// Recursively call for left and right subtrees and store the sum as new value of this node

node->data = toSumTree(node->left) + toSumTree(node->right);

// Return the sum of values of nodes in left and right subtrees and

// old_value of this node

return node->data + old_val;

}

This has the complexity of O(n).

Explanation:

You might be interested in
Cliff just started working with a client who has a very disorganized AdWords account. What’s an effective way for him to begin r
scoundrel [369]
AdWords is a service which helps to create online advertisements. It's needed to promote your business, by increasing popularity of your website or selling your products. The most effective way for Cliff is to c<span>reate campaigns based on the structure of his client’s website. He should divide his client's account into several campaigns according to website's structure.</span>
7 0
3 years ago
Jeffrey works with a huge database of spreadsheet records each day. To organize and identify these spreadsheets, he wants to ass
mariarad [96]

Answer:

A. Document Properties

B. Permission

C. Document Options

D. File Details

The answer to this question is "File Details " . This will help Jeffrey works efficiently with a huge database of spreadsheet records each day. He can assign names to these File Details which represents each spreadsheet records. This will help his report more organized and easy to identity.

8 0
3 years ago
On your Windows server, you’re planning to install a new database application that uses an enormous amount of disk space. You ne
iragen [17]

Answer:

3. ReFS

Explanation:

Only in ReFS include  and others do not have all of the below features

1. Automatic integrity checking and data scrubbing

2. Removal of the need for running chkdsk  

3. Protection against data degradation

4. Built-in handling of hard disk drive failure and redundancy

5.  Integration of RAID functionality

6.  A switch to copy/allocate on write for data and metadata updates

7. Handling of very long paths and filenames

8. Storage virtualization and pooling

4 0
3 years ago
What might a programming prefer the top-down approach to programming design?
navik [9.2K]

Top down program design is an approach to program design that starts with the general concept and repeatedly breaks it down into its component parts. In other words, it starts with the abstract and continually subdivides it until it reaches the specific. Consider creating the prime factorization of a number like 1540. The steps involved might look like:

1540

2 x 770

2 x 2 x 385

2 x 2 x 5 x 77

2 x 2 x 5 x 7 x 11

Top down program design works the same way. We start with the overall objective and wind up with a series of steps needed to accomplish it.

3 0
3 years ago
Suggest names for a coding club
bulgar [2K]

Answer:

  • <u>Abstract Connoisseurs.</u>
  • <u>Hypertext Assassins.</u>
  • <u>Callback Cats.</u>
  • <u>Boolean Autocrats.</u>
  • <u>Runtime Terror.</u>

Explanation:

<em><u>Hope it's help you !!</u></em>

3 0
2 years ago
Other questions:
  • In steps<br> Urgent please
    14·1 answer
  • Operational feasibility, which refers to user acceptance and support, as well as management acceptance and support, is also know
    9·1 answer
  • The exponential distribution is often used to model what in a queuing system?
    12·1 answer
  • All systems have ___________.
    9·2 answers
  • Is this App for real?​
    5·1 answer
  • What is the output by the code system.out.print(8-4+2);
    13·1 answer
  • Disuss the roles of hardware,software and databases in regard to computer based information systems
    7·1 answer
  • An MP3 player is an example of which of the following types of computer
    5·1 answer
  • A web-based program that uses artificial intelligence techniques to automate tasks such as searches is called
    8·1 answer
  • Which backup requires a small amount of space and is considered to have an involved restoration process?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!