Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
11th Edition
ISBN: 9780134670942
Author: Y. Daniel 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.
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 content
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
- Fill 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_forwardFind out how well the stack is doing when you have some spare time?arrow_forward
- The disadvantage of array list is: (". a. The size of the array has to be decided from the beginning. b. There is a need to shift data to insert a new item in the list. O c. The space needed for the array is reserved from the beginning. O d. All.arrow_forwardWhat 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_forward
- Java - This project will allow you to compare & contrast different 4 sorting techniques, the last of which will be up to you to select. You will implement the following: Bubble Sort (pair-wise) Bubble Sort (list-wise) [This is the selection sort] Merge Sort Your choice (candidates are the heap, quick, shell, cocktail, bucket, or radix sorts) [These will require independent research) General rules: Structures can be static or dynamic You are not allowed to use built in methods that are direct or indirect requirements for this project – You cannot use ANY built in sorting functions - I/O (System.in/out *) are ok. All compare/swap/move methods must be your own. (You can use string compares) Your program will be sorting names – you need at least 100 unique names (you can use the 50 given in project #3) – read them into the program in a random fashion (i.e. not in any kind of alpha order). *The more names you have, the easier it is to see trends in speed. All sorts will be from…arrow_forwardJAVA Help: Mergesort Implement a natural merge sort for linked lists. (This is the method of choice for sorting linked lists because it uses no extra space and is guaranteed to be linearithmic.) During each iteration, natural merge sort works by scanning the list from the left to right identifying naturally sorted sub-lists and merging the sub-lists, and continue scanning further identifying and merging the sub-lists until the end of the list. Repeats the process until the entire list is sorted. Example: Unsorted list M -> E -> R -> G -> E -> S -> O -> R -> T -> E -> X -> A -> M -> P -> L -> E After first iteration: E - > M -> R -> E -> G -> S -> E -> O -> R -> T -> X -> A -> L -> M -> P -> E After second iteration: E -> E -> G -> M -> R -> S -> A -> E -> L -> M -> 0 -> P -> R -> T -> X -> E After third iteration: A -> E -> E -> E -> G…arrow_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
- Create a data type that allows you to insert, delete the maximum, and delete the minimum (all in logarithmic time), as well as find the maximum and find the minimum (both in constant time). Tip: Use two heaps.arrow_forwardActivity Research for heap sort and its uses. Now, your task is to create an array of names that includes the names of your grandparents, parents, and your siblings. Using heap sort, arrange these names alphabetically. List down the names first, then do heap sort right after.arrow_forward6. the grade is under 20 which is outlier, remove it from the array list. 7. Print array list using System.out.println() 8. Use indexOf to print index of 80. 9. Use get function. 10. What is the difference between get and index of? 11. Print the values of the array list using Iterator class. 12.. Delete all the values of the array list using clear function. 13. Print all the values of the array after you execute clear using System.out.println(). what is the result of using clear function? 14. What is the shortcoming of using array List?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