subject

Procedure TreeSearch (x, K) i if (x = NIL) or (K = x. key) then 2 return (x); 3 else if (K < x. key) then 4 | TreeSearch (x. left, K); 5 else 6 TreeSearch (x. right, K); 7 endConsider 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 rooted at v.

We wish to add an operation SumLE(K) to this binary search tree which returns the sum of all the keys in the tree whose values are less than or equal to K.

(a) Describe an algorithm, SumLE(K), which returns the sum of all the keys in the tree whose values are less than or equal to K. Give pseudo-code for your algorithm. Your algorithm should take the same time as operation TreeSearch from slide 7.12.

(b) Explain why your algorithm is correct, i. e., why it returns the sum of all the keys whose values are less than or equal to K.

(c) Analyze the running time of your algorithm in terms of the size n and height h of the binary search tree.

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 24.06.2019 17:40
This assignment continues work on the online booking facility introduced at the end of chapter- 10. the work will be continued in the assignments for chapters 14 and 15 (a) assume that you will produce your online booking facility using an agile approach. i. suggest the kind of user research you would like to conduct for your product before iteration cycles begin. ii prioritize the requirements for your product according to business value, i.e which requirements are likely to provide the greatest business benefit, and sketch out the ux design work you would expect to undertake during the first four iteration cycles, i.e. cycle 0, and cycles 1 to 3. (b) using one of the mockup tools introduced above, generate a mockup of your product's landing page, as developed in the assignment for chapter-11 (c) using one of the patterns websites listed previously, identify suitable interaction patterns for elements of your product, and develop a software-based prototype that incorporates all the feedback and the results of the user experience mapping achieved at the end of chapter-11. if you do not have experience in using any of these, create a few html web pages to represent the basic structure of your website
Answers: 2
question
Computers and Technology, 24.06.2019 22:30
In writing a paper for his english class, gavin quoted an author of the book. what should he include in his paper to credit the source? citation caption header entry
Answers: 1
question
Computers and Technology, 25.06.2019 02:30
One important thing in finding employment is to get your resume noticed and read.true or false
Answers: 2
question
Computers and Technology, 25.06.2019 03:40
Acurrent vehicle registration expires at of the first owner listed on the registration form. a. stretch and flex b. bend and break c. wear down d. bounce around
Answers: 1
You know the right answer?
Procedure TreeSearch (x, K) i if (x = NIL) or (K = x. key) then 2 return (x); 3 else if (K < x. k...
Questions
question
Law, 02.09.2020 01:01
question
Mathematics, 02.09.2020 01:01
question
Mathematics, 02.09.2020 01:01
question
History, 02.09.2020 01:01
question
Physics, 02.09.2020 01:01
question
Chemistry, 02.09.2020 01:01
Questions on the website: 13722367