Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing Fundamentals, Design, and Implementation

Authors: David M. Kroenke, David J. Auer

14th edition

133876705, 9781292107639, 1292107634, 978-0133876703

More Books

Students also viewed these Databases questions