Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
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 ...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