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