Question
How would you represent a d-ary heap in an array? Answer this question by: Giving an expression for J-th-Child(i,j): the index of the j-th child
How would you represent a d-ary heap in an array?
Answer this question by:
Giving an expression for J-th-Child(i,j): the index of the j-th child as a function of the index i of the given node, and the child index j within the given node.
Giving an expression for D-Ary-Parent(i): the index of the parent of a node as a function of its index i within the array.
Checking that your solution works by showing that D-Ary-Parent(J-th-Child(i,j)) = i (when you start at node i, and apply your formula to go to a child, and then your other formula to go back to the parent, you must end up back at i).
Step by Step Solution
There are 3 Steps involved in it
Step: 1
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