Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question B) only please This question is about heaps and in this question the Heap is a max Heap. (a) What is the minimum number

image text in transcribedQuestion B) only please

This question is about heaps and in this question the Heap is a max Heap. (a) What is the minimum number of elements that must be moved during a "retrieve the maximum element operation on a heap? Give an example of a heap with 7 elements for which a "retrieve the maximum element operation will require this minimum number of moves. (b) Provide an implementation of the method delete (self, k) that deletes from a Heap the element at position k. You can assume that the heap's elements are numbers stored in an array called array (with the root at position 1), that you have an instance variable count, and that the Heap has the following methods: sink (self, k) rise (self, k) swap (self, i, j). This question is about heaps and in this question the Heap is a max Heap. (a) What is the minimum number of elements that must be moved during a "retrieve the maximum element operation on a heap? Give an example of a heap with 7 elements for which a "retrieve the maximum element operation will require this minimum number of moves. (b) Provide an implementation of the method delete (self, k) that deletes from a Heap the element at position k. You can assume that the heap's elements are numbers stored in an array called array (with the root at position 1), that you have an instance variable count, and that the Heap has the following methods: sink (self, k) rise (self, k) swap (self, i, j)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

A Complete Guide To Environmental Audits Self Policing For Environmental Protection

Authors: Elizabeth Glass Geltman

1st Edition

1570733813, 978-1570733819

More Books

Students also viewed these Accounting questions