Answered step by step
Verified Expert Solution
Question
1 Approved Answer
3. For an array A= aj, 02, 03, 04 of distinct numbers, there are two main ways to build a heap, as described in class.
3. For an array A= aj, 02, 03, 04 of distinct numbers, there are two main ways to build a heap, as described in class. In parts (a) and (b) of this problem you must show what comparisons each method will make, in the form of a binary decision tree. Each leaf should contain output in the form of some permutation of the input subscripts in A (e.g., if you write 3124 it means that after building the heap we have A = [a3, 41, 42, 04]. (a) Do the above (draw the decision tree) for the forward method. (b) Do the above (draw the decision tree) for the reverse method. (c) Describe your own heap-building algorithm that specifically handles inputs of size 4, and draw the corresponding decision tree that uses fewer decisions in the worst-case compared to the methods in (a) and (b). Your algorithm should be described in En- glish, not pseudocode. 3. For an array A= aj, 02, 03, 04 of distinct numbers, there are two main ways to build a heap, as described in class. In parts (a) and (b) of this problem you must show what comparisons each method will make, in the form of a binary decision tree. Each leaf should contain output in the form of some permutation of the input subscripts in A (e.g., if you write 3124 it means that after building the heap we have A = [a3, 41, 42, 04]. (a) Do the above (draw the decision tree) for the forward method. (b) Do the above (draw the decision tree) for the reverse method. (c) Describe your own heap-building algorithm that specifically handles inputs of size 4, and draw the corresponding decision tree that uses fewer decisions in the worst-case compared to the methods in (a) and (b). Your algorithm should be described in En- glish, not pseudocode
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