Question: i Problem 3: 25 pts) Let A be an array of n elements. A heavy element of A is any element that appears more than

 i Problem 3: 25 pts) Let A be an array of

i Problem 3: 25 pts) Let A be an array of n elements. A heavy element of A is any element that appears more than 2n/5 times, i.e., is more than 40% of the items. For example, if n = 11 then a heavy element must appear at least 5 times. Note that an array might contain no heavy items, one heavy item or two heavy items. It can not contain more. As examples, consider the arrays A, B and C below: 1234567891011 Ad 3 635 6383 674 123456 7 | 8 | 9 | 10 | 11 Bil 3335 6383 674 1 2 3 4 5 6 7 8 9 10 11 Ci 33366383 666 A contains no heavy items. B contains the unique heavy item 3. C contains the two heavy items 3 and 6. Design an O(n logn) time divide-and-conquer algorithm for finding the heavy items in an array. Your solution should be split into the following three parts. Write the answer to each part separately. (a) (i) Write documented pseudocode for a procedure Heavy(i,j) that returns the set of heavy items in subarray Ali...;). (ii) Below the pseudocode, provide a description in words (as opposed to code) of what your algorithm is doing. (b) Explain (prove) why your algorithm is correct. (c) Let T(n) be the worst case number of total operations of all types performed by your algorithm. Derive a recurrence relation for T(n) (explain how you derived the recurrence relation). Show that T(n) = (n logn). Note: If the recurrer rrence relation is in the form In > 1, T(m) ST (6) +1 () +cin and f(1) = c2 (5) for some c1, c2 > 0 you may immediately conclude that T (n) = O(n logn) without providing any further explanation. This is is essentially what you proved in Problem (1) part (6). Otherwise, you must prove from first principles that whatever recurrence relation you derived implies T(n) = O(n log n) for all values of n. i Problem 3: 25 pts) Let A be an array of n elements. A heavy element of A is any element that appears more than 2n/5 times, i.e., is more than 40% of the items. For example, if n = 11 then a heavy element must appear at least 5 times. Note that an array might contain no heavy items, one heavy item or two heavy items. It can not contain more. As examples, consider the arrays A, B and C below: 1234567891011 Ad 3 635 6383 674 123456 7 | 8 | 9 | 10 | 11 Bil 3335 6383 674 1 2 3 4 5 6 7 8 9 10 11 Ci 33366383 666 A contains no heavy items. B contains the unique heavy item 3. C contains the two heavy items 3 and 6. Design an O(n logn) time divide-and-conquer algorithm for finding the heavy items in an array. Your solution should be split into the following three parts. Write the answer to each part separately. (a) (i) Write documented pseudocode for a procedure Heavy(i,j) that returns the set of heavy items in subarray Ali...;). (ii) Below the pseudocode, provide a description in words (as opposed to code) of what your algorithm is doing. (b) Explain (prove) why your algorithm is correct. (c) Let T(n) be the worst case number of total operations of all types performed by your algorithm. Derive a recurrence relation for T(n) (explain how you derived the recurrence relation). Show that T(n) = (n logn). Note: If the recurrer rrence relation is in the form In > 1, T(m) ST (6) +1 () +cin and f(1) = c2 (5) for some c1, c2 > 0 you may immediately conclude that T (n) = O(n logn) without providing any further explanation. This is is essentially what you proved in Problem (1) part (6). Otherwise, you must prove from first principles that whatever recurrence relation you derived implies T(n) = O(n log n) for all values of n

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!