(ai) (b) (c) (d) (e) Let 27, 21, 9, 43, 37, 83, 123, 33 and 97...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
(ai) (b) (c) (d) (e) Let 27, 21, 9, 43, 37, 83, 123, 33 and 97 be the elements of an array A which represents a binary tree T such that for node A[i] in T, the leftson and rightson are A[21] and A[2i + 1] respectively. Draw the binary tree which the array A represents. [2 marks] Convert the tree into a maxheap. Show the tree after each iteration of your loop condition. You should make reference to the algorithm HeapBottomUp in Appendix D. [3 marks] Determine the computational complexity of HeapBottomUp. Clearly explain all steps in your working. [2 marks] Briefly outline how Heapsort sorts a list of n items in non-decreasing order. [2 marks] You are given a list of one million numbers which are in a random order. How many comparisons would you expect heapsort to take to sort this list? Justify your answer. Activate V [2 marks] to Setting Appendix D: Building a heap ALGORITHM Heap Bottom Up (H[1..n]) //Constructs a heap from elements of a given array // by the bottom-up algorithm //Input: An array H[1..n] of orderable items //Output: A heap H[1..n] for i - [n/2] downto 1 do ki; v heap false H[k] while not heap and 2 * k≤ n do j←2*k if j<n //there are two children if H[j]<H[j+1] j←j+1 if v ≥ H[j] heap ← true else H[k]H[j]; k<j H[k]←v (ai) (b) (c) (d) (e) Let 27, 21, 9, 43, 37, 83, 123, 33 and 97 be the elements of an array A which represents a binary tree T such that for node A[i] in T, the leftson and rightson are A[21] and A[2i + 1] respectively. Draw the binary tree which the array A represents. [2 marks] Convert the tree into a maxheap. Show the tree after each iteration of your loop condition. You should make reference to the algorithm HeapBottomUp in Appendix D. [3 marks] Determine the computational complexity of HeapBottomUp. Clearly explain all steps in your working. [2 marks] Briefly outline how Heapsort sorts a list of n items in non-decreasing order. [2 marks] You are given a list of one million numbers which are in a random order. How many comparisons would you expect heapsort to take to sort this list? Justify your answer. Activate V [2 marks] to Setting Appendix D: Building a heap ALGORITHM Heap Bottom Up (H[1..n]) //Constructs a heap from elements of a given array // by the bottom-up algorithm //Input: An array H[1..n] of orderable items //Output: A heap H[1..n] for i - [n/2] downto 1 do ki; v heap false H[k] while not heap and 2 * k≤ n do j←2*k if j<n //there are two children if H[j]<H[j+1] j←j+1 if v ≥ H[j] heap ← true else H[k]H[j]; k<j H[k]←v
Expert Answer:
Answer rating: 100% (QA)
i Generally the binary representation looks like this ii we will start checking from 43 because afte... View the full answer
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these computer network questions
-
You work on a team within a larger office. You have a good friendship with a team leader in another group but still, you're just work friends. At lunch, they tell you they have been very stressed...
-
2 Broken Hearts In a study of 900 randomly selected Americans, data are collected for whether or not the subject has had a heart attack (attack = 1 if had a heart attack, 0 otherwise) along with...
-
Jaeger, Inc. bonds have a 9.78% coupon rate with semi-annual coupon payments. They have 19 years to maturity and a par value of $1,000. What is the current yield of the bond if the bond is selling at...
-
Calculate the labour turnover rate according to replacement method from the following: No. of workers on the payroll: - At the beginning of the month: 500 - At the end of the month: 600 During the...
-
Presented below is information related to P. J. Harvey Company for 2008. Retained earnings balance, January 1, 2008.................................................$980,000 Sales for the...
-
The impact of technology on internal controls includes a. Reduced processing errors. b. Elimination of the need for regular audits. c. Elimination of the need to bond employees. d. More efficient...
-
The patterns of values and philosophies that outwardly reject those of the larger organization or social system are called _____________. (a) sagas (b) organizational development (c) rituals (d)...
-
Kim Yi has prepared the following list of statements about accounts. 1. An account is an accounting record of either a specific asset or a specific liability. 2. An account shows only increases, not...
-
Rotations are based on circle 360 start to finish. Look at the figures and try to match them to the degrees they are rotated either clockwise or counterclockwise to map each one onto itself. A. B. C....
-
The Scottie Sweater Company produces sweaters under the "Scottie" label. The company buys raw wool and processes it into wool yarn from which the sweaters are woven. One spindle of wool yarn is...
-
bled: OOC - MH Lab 2: Cost-Volume-Profit i Saved Frieden Company's contribution format income statement for the most recent month is given below: Sales (47,000 units) Variable expenses Contribution...
-
Kerr receives an annual $25,700 base salary for sales work. A quota of $900,000 in sales has been set. Kerr receives an 8 percent commission on all sales in excess of $900,000. This year, his annual...
-
Multiply. (5y-2)(8y+3)
-
How does the motif of the double or doppelgnger function in Gothic literature? Examine its symbolic significance and its psychological implications in the context of exploring human identity and...
-
The records of Barclay Corporation for the year ended December 31, 2022 show the following: Net Income Sales Revenue Loss on sale of land Acquisition of land 2000 Depreciation expense Decrease in...
-
Ethical leaders often use a process for sound and practical decision-making. Evaluate and explain a decision-making technique or aid to solve problems in leadership that we have learned or from your...
-
Most of us communicate regularly through email and texting whether it is socially, for business purposes or for distance learning. Email and texting can be great communication tools, but they have...
-
Identify the source of funds within Micro Credit? How does this differ from traditional sources of financing? What internal and external governance mechanisms are in place in Micro Credit?
-
Kathy Kennedy (age 44) is a single taxpayer and she lives at 212 North Pine Way, Payson, AZ 85541. Her Social Security number is 467-98-9784. Kathy's earnings and income tax withholding as the...
-
Leslie is a single taxpayer who is under age 65 and in good health. For 2012, she has a salary of $23,000 and itemized deductions of $1,000. Leslie is entitled to one exemption on her tax return. a....
-
Clifford Johnson has a limited partnership investment and a rental condominium. Clifford actively manages the rental condominium. During 2012, his share of the loss from the limited partnership was...
-
Is the of a diversified conglomerate close to 1? Why?
-
As a result of a change in the nature of its business, there is a relative rise in the proportion of fixed costs in a group As total costs. Will this affect the risk attached to its share price? If...
-
What law of statistics explains that in the long term, risk disappears? State your views.
Study smarter with the SolutionInn App