you have a version of binary heap where each nonleaf node has x children instead of 2 1)how to represent such a heap using arrays.
you have a version of binary heap where each nonleaf node has x children instead of 2
1)how to represent such a heap using arrays. Show how to reach to the children nodes and parent nodes. For binary heap, given a node at position i, its left and right children are at positions 2i and 2i+1, respectively. Also given a non-root node at position i, its parent node is at position i/2. Derive these formulas for your generic heap. Justify your answer.
2) what is the height of the heap tree in terms of n and x where n is the total number of elements in the heap and x is the number of children each non-leaf node could have? Justify your answer. Remember that for binary heap, its height is
Step by Step Solution
There are 3 Steps involved in it
Step: 1
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