about | help | code help+videos | done | prefs |
norm.krumpe@muohio.edu heapmethods
Solve the following problems related to heaps. In all problems, the heaps are meant to be max heaps (largest value is at the top of the heap). In all problems, the first element of the given array is always 0 and is not part of the heap. It is there in order to make heap index calculations easier. So, for example, if a max heap has the three nodes 7, 2, and 6, it would be shown as [0, 7, 2, 6].
In codingbat, all methods must return values. Even though a method that modifies the values in an array will not normally need to return an array, you still need to do that in codingbat. Thus the add and remove methods below return the modified array.
Before you solve the problems below, be sure to:
* Log in to codingbat.com, so that your work is saved to your account.
* Go to the "prefs" page on CodingBat and share your work with this e-mail address: norm.krumpe@muohio.edu
Solve these three problems using the algorithms and heap definitions from class:
isMaxHeap
addToMaxHeap
removeMaxFromHeap
Authoring docs
Copyright Nick Parlante 2017 - privacy