#8 Perform a two deletions on the following binary heap. Enter the resulting heap and draw the heaped tree too:

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

#8 Perform a two deletions on the following binary heap. Enter the resulting
heap and draw the heaped tree too:

4
8
9
12
9.
10
3
After dequeue:
Transcribed Image Text:4 8 9 12 9. 10 3 After dequeue:
Expert Solution
Step 1

Given Array:

{2, 3, 4, 8, 9, 12, 9, 10}

Forming Min heap from the array:

Computer Science homework question answer, step 1, image 1

Note: Since your are not mentioning the order of the heap, here we are using minimum heap order.

Step 2

Steps to deque an element from the array:

  • Remove the minimum element from the heap.
  • Replace the removed element with last node of the heap.
  • Compare the values with child, if there a need for swap, swap the nodes.
  • Continue this until, the heap to satisfies to its conditions.
Step 3

Removing minimum element from the heap:

Computer Science homework question answer, step 3, image 1

Step 4

Replacing the root node with final leaf node(12):

Computer Science homework question answer, step 4, image 1

Step 5

Comparing the root node with child node:

Here, the value of root is 12 and the value of minimum child node is 3. Therefore, swap the nodes.

Computer Science homework question answer, step 5, image 1

Now, again swap the node 12 with node 8, because node 8 is the minimum than node 12.

Computer Science homework question answer, step 5, image 2

The above heap represents the deletion of first deletion.

Again, follow the same process for second deletion.

steps

Step by step

Solved in 9 steps with 9 images

Blurred answer
Knowledge Booster
Operations of Fibonacci Heap
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education