Question: An n-ary tree is a tree where every node has at most n children. An n-ary heap is an n-ary tree that has the

An n-ary tree is a tree where every node has at most n children. An n-ary heap is an n-ary tree that has the

An n-ary tree is a tree where every node has at most n children. An n-ary heap is an n-ary tree that has the heap properties (left-complete and partially ordered). Assume that an n-ary heap will never contain more than n elements in total. a) What can you say about the shape (height, width, size of each level) of an n-ary heap? How is it represented as an array? Why? b) Describe (in words) an algorithm to insert an element into an n-ary heap, and express its running time asymptotically. Justify your answer. c) Describe (in words) an algorithm to delete the largest element from an n-ary heap, and express its running time asymptotically. Justify your answer. d) Can an n-ary heap be using to implement heapsort? Is it a good idea? Why? e) When is an n-ary heap better than a binary heap? Why?

Step by Step Solution

3.27 Rating (147 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Answer a Shape of an nary Heap Height The height of an nary heap is determined by the number of elements in the heap and the arity n The height hh is ... View full answer

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 Programming Questions!