8 A min-max heap is a data structure that supports both deleteMin and deleteMax | StudySoup

Textbook Solutions for Data Structures and Algorithm Analysis in Java

Chapter 6 Problem 6.18

Question

8 A min-max heap is a data structure that supports both deleteMin and deleteMax inO(logN) per operation. The structure is identical to a binary heap, but the heaporderproperty is that for any node, X, at even depth, the element stored at X issmaller than the parent but larger than the grandparent (where this makes sense),and for any node X at odd depth, the element stored at X is larger than the parentbut smaller than the grandparent. See Figure 6.57.a. How do we find the minimum and maximum elements?b. Give an algorithm to insert a new node into the min-max heap.c. Give an algorithm to perform deleteMin and deleteMax. d. Can you build a min-max heap in linear time?e. Suppose we would like to support deleteMin, deleteMax, and merge. Propose adata structure to support all operations in O(logN) time.

Solution

Step 1 of 5)

The first step in solving 6 problem number 18 trying to solve the problem we have to refer to the textbook question: 8 A min-max heap is a data structure that supports both deleteMin and deleteMax inO(logN) per operation. The structure is identical to a binary heap, but the heaporderproperty is that for any node, X, at even depth, the element stored at X issmaller than the parent but larger than the grandparent (where this makes sense),and for any node X at odd depth, the element stored at X is larger than the parentbut smaller than the grandparent. See Figure 6.57.a. How do we find the minimum and maximum elements?b. Give an algorithm to insert a new node into the min-max heap.c. Give an algorithm to perform deleteMin and deleteMax. d. Can you build a min-max heap in linear time?e. Suppose we would like to support deleteMin, deleteMax, and merge. Propose adata structure to support all operations in O(logN) time.
From the textbook chapter Priority Queues (Heaps) you will find a few key concepts needed to solve this.

Step 2 of 7)

Visible to paid subscribers only

Step 3 of 7)

Visible to paid subscribers only

Subscribe to view the
full solution

Title Data Structures and Algorithm Analysis in Java 3 
Author Mark A. Weiss
ISBN 9780132576277

8 A min-max heap is a data structure that supports both deleteMin and deleteMax

Chapter 6 textbook questions

×

Login

Organize all study tools for free

Or continue with
×

Register

Sign up for access to all content on our site!

Or continue with

Or login if you already have an account

×

Reset password

If you have an active account we’ll send you an e-mail for password recovery

Or login if you have your password back