(This project requires that you know what a stack is and how to use dynamic arrays. Stacks are covered in Chapter 14; dynamic arrays are covered in Chapter 9. This is an appropriate project only if you have covered Chapters 9 and 14.) Write a template version of a stack class. Use a type parameter for the type of data that is stored in the stack. Use dynamic arrays to allow the stack to grow to hold any number of items.
Want to see the full answer?
Check out a sample textbook solutionChapter 17 Solutions
Problem Solving with C++ (10th Edition)
Additional Engineering Textbook Solutions
Database Concepts (8th Edition)
Degarmo's Materials And Processes In Manufacturing
Introduction To Programming Using Visual Basic (11th Edition)
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
Modern Database Management
INTERNATIONAL EDITION---Engineering Mechanics: Statics, 14th edition (SI unit)
- P1.arrow_forwardNote: If it needs to be programmed/codes, please do it in C++. Thank you so much. Arr[]= [ 10, 30, 40, 70. 100. 120, 150];arrow_forwardPython: Take your searching and sorting functions and put them into a class. The constructor should take a list as a parameter use the classes sort method and store the sorted list in a class property. A "search" method should return true or false if the item is found. A "count" method should return 0 or the number of times the item is found. For fun, you can create a method to generate a list of random numbers (and then sort it).arrow_forward
- In the C programming language Suppose you are given an array of integers. You want to insert a number x to the array and rearrange so that all the elements are less than or equal to x are before x, and the elements after x are greater than x. For example, suppose the list is {3, 2, 7, 0 1, 5}and x is 4, since3, 2, 0, and 1,are less than or equal to 4,7and 5 are greater than 4, the new array is {3, 2, 0, 1, 4, 7, 5}.The new array has the length of n+1 where n is the length of the input array. Example input/output #1: Enter the length of the array: 10 Enter the elements of the array: 3 5 14 03 92 8 11 Enter the number for insertion: 3 Output: 3 1 0 3 2 3 5 4 9 8 11 Example input/output #2: Enter the length of the array: 8 Enter the elements of the array: 5013 4 1 7 3 5 Enter the number for insertion: 6 Output: 5 0 4 1 356 13 7 1) Name your program arrays.c 2) Include the rearrange( ) function to rearrange the array: void rearrange(int *a, int n, int insert, int *b); a…arrow_forwardmergeAndRemove(int[], int[]) This is a public static function that takes a int[] and int[] for the parameters and returns an int[]. Given two arrays of integers. Your job is to combine them into a single array and remove any duplicates, finally return the merged array.arrow_forwardYou will create two programs. The first one will use the data structure Stack and the other program will use the data structure Queue. Keep in mind that you should already know from your video and free textbook that Java uses a LinkedList integration for Queue. Stack Program Create a deck of cards using an array (Array size 15). Each card is an object. So you will have to create a Card class that has a value (1 - 10, Jack, Queen, King, Ace) and suit (clubs, diamonds, heart, spade). You will create a stack and randomly pick a card from the deck to put be pushed onto the stack. You will repeat this 5 times. Then you will take cards off the top of the stack (pop) and reveal the values of the cards in the output. As a challenge, you may have the user guess the value and suit of the card at the bottom of the stack. Queue Program There is a new concert coming to town. This concert is popular and has a long line. The line uses the data structure Queue. The people in the line are objects…arrow_forward
- OCaml Code: The goal of this project is to understand and build an interpreter for a small, OCaml-like, stackbased bytecode language. Make sure that the code compiles correctly and provide the code with the screenshot of the output. The code must have a function that takes a pair of strings (tuple) and returns a unit. You must avoid this error that is attached as an image. Make sure to have the following methods below: -Push integers, strings, and names on the stack -Push booleans -Pushing an error literal or unit literal will push :error: or :unit:onto the stack, respectively -Command pop removes the top value from the stack -The command add refers to integer addition. Since this is a binary operator, it consumes the toptwo values in the stack, calculates the sum and pushes the result back to the stack - Command sub refers to integer subtraction -Command mul refers to integer multiplication -Command div refers to integer division -Command rem refers to the remainder of integer…arrow_forward1) What is one main disadvantage of an ArrayList? 2) Write a Java statement to create an ArrayList called list to hold 25 integers. 3) What is the type of the ArrayList defined in question number 2? 4) Write a for loop to initialize the objects in the ArrayList created in question number 2 above to -1.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
- Need help with this in Java Implement a “To Do” list. Tasks have a priority between 1 and 9, and a description (which you can come up with on your own, say, “wash dishes”). The program is going to prompt the user to enter the tasks by running the method add_priority_description, the program adds a new task and prints the current list with priority 1 tasks on the top, and priority 9 tasks at the bottom. The program will continue to ask the user if they want to add another tasks, and repeat the add_priority_description method, or enters Q to run the quit method to quit the program. Sample output (not limited to) 1. Study for the final 1. Take the final 2. Watch Justice League with friends 3. Play ball 9. Wash Dishes 9. Clean room. There is a possibility of two tasks having the same priority. If so, the last task that was entered gets to be printed first. Use HEAP in your solution. (Java)arrow_forwardAssume s1,s2 are two stacks and we write s1=s2 , if the class stack based on array then إختر أحد الخيارات: a. This statement is good to use when s1 has small number of items b. This statement is good to use when s2 has large number of items c. This statement is good to use when s2 has small number of items d. This statement is good to use when s1 has large number of items أخلِ اختياريarrow_forwardI asked this once before but it came up incorrect somehow so I'll submit this one again. Write a program in C# named ArrayDemo that stores an array of 10 integers. (Note that the array is created for you and does not need to be changed.) Until the user enters a sentinel value, allow the user four options: (1) to view the list in order from the first to last position in the stored array (2) to view the list in order from the last to first position (3) to choose a specific position to view (4) to quit the application. -------- using System; using static System.Console; class ArrayDemo { static void Main() { int[] nums = {7, 6, 3, 2, 10, 8, 4, 5, 9, 1}; // Write your main here } }arrow_forward
- 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