Introduction to Java Programming and Data Structures Comprehensive Version (11th Edition)
11th Edition
ISBN: 9780134700144
Author: Liang
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Chapter 23.6, Problem 23.6.4CP
Program Plan Intro
Complete binary tree:
- A binary tree is said to be a complete if every level of the tree are full except the last level.
- The last level need not be full and all the leaves on the last level are placed left most.
Heap:
- A heap is considered to be binary tree if it has following properties
- When it is complete binary tree.
- Every node is greater than or equal to its children.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Show the resulting heap after 33, 22, and 8 are added to the following heap
50 30 40 20 10 25 35 10 5
1.
Heap and Heapsort.
(a) Run Build-Heap on the array [10, 9,4,7,6,2,3,1, 8,5] to construct a min heap. Write down the resulting
array. Then, run the loop in Heapsort for three iterations. For each iteration write down the array after
Heapify-Down is finished. You do not need to show intermediate steps.
(b) Show that the leaves of a heap occupy the positions [],...,n-1 of the array.
(c) In the procedure Build-Heap, why do we decrease i from [2]-1 to 0 instead of increasing from 0 to
[2]-1? Give an example array where increasing i fails to create a valid min heap.
4. Draw a new heap that is created by inserting 52 into the following heap:
100
71
67
68 50
44
51
60 49 25
30
Chapter 23 Solutions
Introduction to Java Programming and Data Structures Comprehensive Version (11th Edition)
Ch. 23.2 - Prob. 23.2.1CPCh. 23.2 - Prob. 23.2.2CPCh. 23.2 - Prob. 23.2.3CPCh. 23.3 - Prob. 23.3.1CPCh. 23.3 - Prob. 23.3.2CPCh. 23.3 - Prob. 23.3.3CPCh. 23.4 - Prob. 23.4.1CPCh. 23.4 - Prob. 23.4.2CPCh. 23.4 - What is wrong if lines 615 in Listing 23.6,...Ch. 23.5 - Prob. 23.5.1CP
Ch. 23.5 - Prob. 23.5.2CPCh. 23.5 - Prob. 23.5.3CPCh. 23.5 - Prob. 23.5.4CPCh. 23.6 - Prob. 23.6.1CPCh. 23.6 - Prob. 23.6.2CPCh. 23.6 - Prob. 23.6.3CPCh. 23.6 - Prob. 23.6.4CPCh. 23.6 - Prob. 23.6.5CPCh. 23.6 - Prob. 23.6.6CPCh. 23.6 - Prob. 23.6.7CPCh. 23.6 - Prob. 23.6.8CPCh. 23.6 - Prob. 23.6.9CPCh. 23.7 - Prob. 23.7.1CPCh. 23.7 - Prob. 23.7.2CPCh. 23.8 - Prob. 23.8.1CPCh. 23 - Prob. 23.1PECh. 23 - Prob. 23.2PECh. 23 - Prob. 23.3PECh. 23 - (Improve quick sort) The quick-sort algorithm...Ch. 23 - (Check order) Write the following overloaded...Ch. 23 - Prob. 23.7PECh. 23 - Prob. 23.8PECh. 23 - Prob. 23.10PECh. 23 - Prob. 23.11PECh. 23 - Prob. 23.12PECh. 23 - Prob. 23.13PECh. 23 - (Selection-sort animation) Write a program that...Ch. 23 - (Bubble-sort animation) Write a program that...Ch. 23 - (Radix-sort animation) Write a program that...Ch. 23 - (Merge animation) Write a program that animates...Ch. 23 - (Quicksort partition animation) Write a program...Ch. 23 - (Modify merge sort) Rewrite the mergeSort method...
Knowledge Booster
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
- Construct a minheap with the following numbers and answer the question according to the minheap.30, 80, 12, 28, 42, 78, 17, 71, 32, 48, 16, 59, 63, 14, 79 How many levels are there in the heap?arrow_forwardPart A - Heapsort We have included code in Java for a Binary Heap implementation.The first task is to use the heap to sort three separate arrays. The sorted arrays do not have to be ”in place” Use the implementation of the Binary Heap to:(a) Sort a list of floats from high to low.(b) Sort a list of strings alphabetically.(c) Sort integers by their second digit only (low to high). Here is the rest of code: import java.util.ArrayList; public class TestHeap { public static void main(String[] args) { ArrayList<Integer> list = new ArrayList<Integer>(); list.add(8); list.add(5); list.add(12); list.add(12); list.add(15); list.add(20); list.add(8); list.add(5); list.add(18); list.add(5); BinaryHeap<Integer> heap = new BinaryHeap<Integer>(new MaxIntegerComparorator()); heap.buildHeap(list); heap.display(); } } import…arrow_forwardDraw a max heap for the following input: 5, 76, 21, 33, 98, 8, 50, 37, 7, 9, 100, 29, 49, 95, 99. You need to show the swaps.arrow_forward
- 4. Build a Max-Heap on the following array A= Show all the steps.arrow_forwardWe can build a heap by top-down (iterated insertion), or by bottom-up. Given the numbers 10, 9, 12, 13, 14, 8 a. run the bottom-up algorithm to create a heap and show the resulting heap and ALLsteps b. run the top-down algorithm to create heap and show the resulting heap and ALLstepsarrow_forwardShow your correct work.arrow_forward
- 2. Draw the following list of numbers as a heap with the first number as the root: 77, 66, 55, 44, 60, 33, 55. After that insert 40.arrow_forward4. Given an array, arr[] = {90, 15, 10, 7, 12, 2), does this array represents a Max-Heap? if it does, draw this max-heap.arrow_forwardWhat is the depth of a binary heap with 100 nodes (assume the root is on depth 0)?arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
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)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education