Question: Problem 2-2. [20 points] Heap Practice (a) [10 points] For each array below, draw it as a left-aligned complete binary tree and state whether the
![Problem 2-2. [20 points] Heap Practice (a) [10 points] For each](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f2d75b6fa63_87466f2d75ac46cd.jpg)
Problem 2-2. [20 points] Heap Practice (a) [10 points] For each array below, draw it as a left-aligned complete binary tree and state whether the tree is a max-heap, a min-heap, or neither. If the tree is neither, turn the tree into a max-heap by repeatedly swapping adjacent nodes of the tree. You should communicate your swaps by drawing a sequence of trees, with each tree de- picting one swap. 1. [0, 10, 5, 23, 12, 8, 240] 2. [17, 7, 16, 5, 6, 2] 3. [7, 12, 7, 12, 14, 18, 10] 4. [8, 5, 10, 7, 1, 2, 12] (b) [10 points] Consider the following binary tree on seven nodes labeled A-G. B- E F G Each node stores a key from the multiset X = {6,5, 3, 2, 6, 1,4} so as to satisfy the max-heap property (there are two 6s in X, so exactly two nodes will store a 6). For each node in {A, B, C, D, E, F, G), list the key values that could be stored there
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
