(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...
-
The online reviews had familiar ring, and it was not pleasant. "Great book, too many error." "The errors distracted from the story." Was I missing something? Like spell-check?" "Who published this? A...
-
How much you smile in your younger days can predict your later success in marriage (msnbc.com, April 16, 2009). The analysis is based on the success rate in marriage of people over age 65 and their...
-
What is the law of the excluded middle? Argue against the need for this law.
-
Koch Chemical Company makes a variety of cosmetic products, one of which is a skin cream designed to reduce the signs of aging. Koch produces a relatively small amount (15,000 units) of the cream and...
-
Consider the configuration of current-carrying wires shown below. Two semi-infinite wires carry equal currents I and I2, each with magnitude Io as shown. These wires meet at Point A, where their...
-
On May 1, a petty cash fund was established for $150. The following vouchers were issued during May: Date Voucher No. Purpose Amount May 1 1 postage due $ 3.50 3 2 office supplies 11.00 5 3 auto...
-
Select the necessary words from the list of possibilities to complete the following statements. 1. Audit reports issued under GAAS ordinarily are signed with the name of the Statements 2....
-
A start-up software company hires Kiera as its first human resource manager. Whenever a new position needs to be filled, Kiera sits down with the supervisor to gather facts that will be included in a...
-
Question 1 (10 marks) Referring to Table 1, we consider a portfolio of three bonds: A, B and C with various probabilities of default. Assuming that (1) the credit exposures are constant, (2) the...
-
Joyner Companys income statement for Year 2 follows: Sales $ 714,000 Cost of goods sold 358,000 Gross margin 356,000 Selling and administrative expenses 217,000 Net operating income 139,000...
-
You make monthly payments of $1,700 on a house mortgage loan. You have just made a payment. The mortgage has 26 years remaining. Show the timeline of the loan from the bank's perspective. Month:...
-
ENAPA Manufacturing Company Limited commenced business on 1st March, 2016 making accounts to 31st December each year. The following assets were acquired for use in the business: Asset Date of...
-
Draw the outputs of the circuits to scale according to the input signal. b) V 0 -20 V -20 V C www 400+ 10V m 2. R 19
-
A 6-lb shell moving with a velocity ?? v0k explodes at point D into three fragments which hit the vertical wall at the points indicated. Fragments A, B, and C hit the wall 0.010 s, 0.018 s, and 0.012...
-
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...
-
The following tables present the number of specimens that tested positive for Type A and Type B influenza in the United States during the first 15 weeks of a recent flu season. a. Find the mean and...
-
The following table presents the circulation (in thousands) for the top 25 U.S. daily newspapers in both print and digital editions. a. Find the mean and median circulation for print editions. b....
-
The following data represent the annual costs in dollars, of a sample of 22 popular magazine subscriptions. a. Find the mean annual subscription cost. b. Find the median annual subscription cost. c....
Study smarter with the SolutionInn App