Question: 1. (k-ary min-heaps) A k-ary heap is like a binary heap, except that non-leaf nodes have k children (except possibly for one node that can
1. (k-ary min-heaps) A k-ary heap is like a binary heap, except that non-leaf nodes have k children (except possibly for one node that can have fewer children). Like binary heaps, k-aryheaps can be stored in an array (in layers, starting from the root). In this problem, you will implement k-ary heaps (on Vocareum). You will have to supportinsertion and extraction. Unlike in the book, we will consider min-heaps for the programmingproblem, since we will need min-heaps later in the course. You may want to look at Problem 6-2 on page 167 of the CLRS book. Youll need to nd formulas for calculating the index of a nodes parent in the array, as wellas the k children of a given node.
The algorithm and the code would be much appreciated! Thanks!
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
