Answered step by step
Verified Expert Solution
Question
1 Approved Answer
question b?e SECTION B (2 QUESTIONS, 42 MARKS) Question 5. 121 marks in total For this question, assume the definition of Javs cles Heap siven
question b?e
SECTION B (2 QUESTIONS, 42 MARKS) Question 5. 121 marks in total For this question, assume the definition of Javs cles Heap siven in the Appedix. a. (2 marks) Consider the Sollowing heap. 30 30. 20, 12, ,6. la uy 20 12 19 6 10 I8 Given the array represettation of a heap discussed in class, ttat is the array that corre- sponds to this heap? b. (5 marks) Successively insert into the heup of part (a.) 22, 35 and II, in that order. Uise the standard wwking. ion algorithen. Show the rgulting heap after each insertion, and intermediste c. (3 marks) Delete the root of the bresp resilting rom the insertions of (b.) above. Use the standard heap delketion algorithm. Sbow the resalting besap, and intertnediate working d. (3 marks) Conskler again the values from the initial bheap given in (a.) (ie. 30, 20, 12, 19, 6, b, 10, I8, 8. Asame you were given these valoes just as a set, and asked to construct a leap, pot nexcessarily using the heaplnsert () operation. Is the heap given in (a.) the only possible beup? If so, explain wby. If bot, give an alternative beap. e. (8 marks) i (6 marks) Write a Java function definrd a follows. The function should use a heap to determine the median of the items in an array of integers a. (This function is not part of the Heap class.) Float heapMed (Integerl a) // pre: array a ot integers is non-enpty // post: heapHed returne zedian of the itens in a i (2 marks) What is the worst-case tine complexity of the funetion beapMed? Page 9Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started