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.2CP
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
Please don't copy the solution from other websites.
Assignment: For this week’s assignment, you’re going to be creating a Heap Sorter. It should be able to take input (using CIN), place it into proper Max Heap form in an array, and once it’s done accepting input, put the array in order using a Heap Sort. For the sake of simplicity, our heap trees will be made of an array that’s only seven elements long. Make sure to define your arrays ahead of time with garbage filler data before you start putting in your CIN data.
Remember to use the binary heap traversal trick when dealing with your array-based tree.
Please sort the following lists of inputs:
1.) 12, 40, 2, 6, 88, 90, 5
2.) 1, 2, 3, 4, 5, 6, 7
3.) 7, 6, 5, 4, 3, 2, 1
4.) 42, 64, 355, 113, 101, 13, 35
5.) 12, -5, 24, -4, 48, -3, 96
C#
Reverse the stack - This procedure will reverse the order of items in the stack. This one may NOT break the rules of the stack. HINTS: Make use of more stacks. Arrays passed as parameters are NOT copies. Remember, this is a procedure, not a function.
This would occur in the NumberStack class, not the main class. These are the provided variables:
private int [] stack;private int size;
Create a method that will reverse the stack when put into the main class.
Objectives:
The code for the different stack and queue operations in both implementations (array and linked list) are
discussed in the lectures: and are written in the lectures power point. So the main object of this
assignment is to give the student more practice to increase their understanding of the different
implementation of these operations.
- The students also are asked to write by themselves the main methods in the different exercises below;
The Lab procedures:
The following files must be distributed to the students in the Lab
// it represents an array implementation of the stack.
// it represents a Linked List implementation of the stack.
arraylmpofStack.java
pointerlmofStack.java
pointerlmofQueue.java // it represents a pointer implementation of the queue.
Then the students by themselves are required to write the code for the following questions
Ex1) Given the file arraylmpofStack.java then write a main method to read a sequence of numbers
and using the stack operation print…
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
- Answer correctly this time else give u bad rating and downvote Using STL stacks, implement an application that does the following: Fill 20 elements into the stack Using an array, sort the elements within the stack using merge sort Place sorted items into the stack again (so your stack becomes sorted) and print the contentarrow_forwardFill in the blanks in each of the following statements (CHOOSE ONLY TEN): 5 AP 1. An --- is created to store information of the method such as the parameters and (0- local variables specific to a given call of the method, and information about which command in the body of the method is currently executing. 21. One application of stack is 32. The type of linked list which is contain more memory space is 3. The --------- operation return the top item of stack. 54. The method used to removes beginning and ending spaces of string 6 5. stack is said underflow when 6. String objects are stored in a special memory area known as 7. Two dimensional array that have a different length is called ----------- A 8. One way to create string object is -------- 10 9. is known as expression. 110. Example of none linear data structures is 12 11. A is a method that contains a statement that makes a call to itself. 13 12. One application of queue isarrow_forwardjava program: If in the ArrayStack, the first element that we push to the stack, is stored in location capacity – 1 (capacity is the capacity of the array theData) in the array theData and the subsequent elements that we push, we keep on adding before the last element added in the array. That is, in the constructor of class ArrayStack, we initialize the topOfStack to capacity and we write the push method as follows: public E push(E obj) { if (topOfStack == 0) reallocate(); topOfStack--; theData[topOfStack] = obj; return obj; } This push method can work but the if statement should be: if (topOfStack == theData.length - 1) reallocate(); This push method will work provided we modify the reallocate method. This push method can work, but topOfStack-- ; should come after theData[topOfStack] = obj; This push method can work, but topOfStack-- ; should be topOfStack++;arrow_forward
- Objectives: The code for the different stack and queue operations in both implementations (array and linked list) are discussed in the lectures: and are written in the lectures power point. So the main object of this assignment is to give the student more practice to increase their understanding of the different implementation of these operations. - The students also are asked to write by themselves the main methods in the different exercises below; The Lab procedures: The following files must be distributed to the students in the Lab - arrayImpOfStack.java // it represents an array implementation of the stack. - pointerImOfStack.java // it represents a Linked List implementation of the stack. - pointerImOfQueue.java // it represents a pointer implementation of the queue. Then the students by themselves are required to write the code for the following questions Ex1) Given the file arrayImpOfStack.java then write a main method to read a sequence of numbers and using the stack…arrow_forwardFind out how well the stack is doing when you have some spare time?arrow_forwardWSP 2: Implement any strategy • You need to extend your WaterSort program to implement one of these strategies. It is a good idea to play around with both – please use Random numbers in both cases. Important: To add ink to a bottle (strategy 1) or to move ink from one bottle to another (strategy 2) or you need to use the stack operators. • You need to ensure that you are not spilling ink! (now you understand why you needed the getSize()) method in Part 1. • You only need to submit one of the two strategies. Your program should have output of 5 scrambled bottles.arrow_forward
- What is the difference between stack and heap memory? Correct choice: A. Heap memory is allocated manually by the user and is 'long-lived'. You must manually allocate it, whereas memory on the stack will be reclaimed when the memory is out of scope from where it was initialized. B. Stack memory is allocated manually by the user and is 'long-lived'. You must manually allocate it, whereas memory on the heap will be reclaimed when the memory is out of scope from where it was initialized.arrow_forwardQ2 Write the number of point and the letter of the correct answer: 1. The number of fields in the node of double linked list as circular is.............. A. 2 B. 3 C. 4 D. 5 2. Which the following can implement by stack? A. recursive problems B. reveres words C. both a and b D. None of the above 3. The infix expression for the postfix expression: ab+c/ is: A. a+b/c B. (a+b)/c C. a+(b/c) D. None of above 4. With queue data structure, The condition last=first indicates that A. queue is empty B. queue is full C. queue has only one element D. None of the above choose the correct answer (data structure in java) 2 10 (0.5X2 Page 1 of 4arrow_forwardstacks and queues. program must be able to handle all test cases without causing an exception Note that this problem does not require recursion to solve (though you can use that if you wish).arrow_forward
- Heap sort is considered: Select one: a. in place and stable b. in place and most efficient c. in place d. stable and most efficient e. stablearrow_forwardPlease help with C++ question in image. Thank you!arrow_forwardCan you please help with this question in the Java programming Languagearrow_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