Using the attached program (AirportCombos.cpp), create a list of strings to process and place on a STL STACK container. The provided code is meant to be generic.
Using the provided 3 char airport codes, create a 6 character string that is the origin & destination city pair. Create all the possible origin/destinations possible combinations from the airport codes provided. Load the origin/destination string onto a stack for processing. Do not load same/same values, such as DALDAL, or LAXLAX. See comments in the program from more details.
After loading the values, Create a loop to display all the values in the container. This loop should inherently remove items as they are displayed.
Deliverable is a working CPP program.
Trending nowThis is a popular solution!
Step by stepSolved in 2 steps
- What is the best way to implement a stack or a queue so that it can hold an arbitrary number of elements? Select one: a. Using an array, and throwing an exception when the stack or queue is full. b. By creating a bigger array when the stack or queue is full, and copying the elements from the original array. c. Using linked lists to store the collection of elements.arrow_forwardWrite a BCPL program that reads a sequence of strings typed by the user and creates a linked list containing them all. But there will be some special command words. These should be obeyed but not inserted into the list An input of END will be used to mark the end of the input sequence. The progrm should stop. An input of ALL means that the whole list should be printed. It is perfectly OK for the list to come out backwards. An input of DELETE means that the next word is to be removed from the list and its memory (for the link object and for the string) must be recycled with freevec (even though freevec doesn't do anything yet). Remember you will need to implement and use strdup(). Remember that strings are packed, four bytes per word, into an array. You use the "byte N of S" syntax to access the individual bytes. Also remember that an extra 0 byte is added to mark the end of the string. Example run: $ run hw4 Enter the strings and deletions: > hello > this > program > works…arrow_forwardWrite a program to sort a stack such that the smallest items are on the top. You can usean additional temporary stack, but you may not copy the elements into any other data structure(such as an array). The stack supports the following operations: push, pop, peek, and is Emptyarrow_forward
- Write a program to sort a stack such that the smallest items are on the top. You can usean additional temporary stack, but you may not copy the elements into any other data structure(such as an array). The stack supports the following operations: push, pop, peek, and is Emptyarrow_forwardS and Q are integer stacks and priority queues, respectively. C mod 3 is the priority of an element C joining the priority queue Q. In other words, the elements' priority numbers are either 0 or 1 or 2. What is the output of the following code if A, B, and C are integer variables? However, the queue procedures have been modified to work on a priority queue. 1.A = 102.B = 113.C = A+B4.while (C < 110) do5. if (C mod 3) = 0 then PUSH (S,C)6. else ENQUEUE (Q,C)7. A = B8. B = C9. C = A + B10.end11.while not EMPTY_STACK (S) do12. POP (S,C)13. PRINT (C)14.end15.while not EMPTY_QUEUE (Q) do16. DEQUEUE (Q, C)17. PRINT (C)18.endarrow_forwardGiven a singly linked list L, where x and y are two data elements that occupy the nodes NODEX and NODEY with PREVIOUSX as the node, which is the previous node of NODEX, write a pseudo-code to swap the date x and y in list L by manipulating the links only (data swapping is not allowed). Assume that x and y are available in the list and are neither neighbors nor the end nodes of list L. For example, given the list L shown in Figure P6.10(a), with L, NODEX, NODEY and PREVIOUSX marked on it, the swapping should yield the list shown in Figure P6.10(b). NODEX and NODEY are neither immediate neighbors nor the end nodes of list L. PREVIOUS X NODE X PREVIOUS X எக்க்கக்கா எத்த்தக்க (a) Before swapping g and x NODE Y NODE Y (b) After swapping g and x Linked Lists 193 NODE X Figure P6.10. Swapping of elements in a singly linked list by manipulating linksarrow_forward
- Suppose you were storing a collection of n words into a container, and wanted to be able to retrieve (find) any word in O(n) time (or faster). Which of the following STL containers would work? SELECT ALL THAT APPLY list priority_queue queue vector set stackarrow_forwardWrite a "C" program, which inputs and then saves school numbers, names, and surnames (Figure 1) into the student automation system. Each record is stored by using a separate linked list, as shown in Figure 2. When a new school number is entered, a record is also added to the stack(s) to be able to sort the numbers by ID (the last four digits of the school numbers), student name, and faculty codes (Figure 2). You can use as many stacks as you want. Your code should (A) Display the student names in ascending order by their IDs. (B) Display the student names in ascending order by the first letter of their names. (C) Display the school numbers by the faculty codes in ascending order. (D) Delete a record by school number. (E) What is the Big-O annotation of each option above? (add the answer of this option as a comment at the beginning of your program code) Your data should be stored in sorted in the stack(s). It is predicted that a lot of sorting will be done by users while using this…arrow_forwardGiven a singly linked list L, where x and y are two data elements that occupy the nodes NODEX and NODEY with PREVIOUSX as the node, which is the previous node of NODEX, write a pseudo-code to swap the date x and y in list L by manipulating the links only (data swapping is not allowed). Assume that x and y are available in the list and are neither neighbors nor the end nodes of list L. For example, given the list L shown in Figure P6.10(a), with L, NODEX, NODEY and PREVIOUSX marked on it, the swapping should yield the list shown in Figure P6.10(b). NODEX and NODEY are neither immediate neighbors nor the end nodes of list L. Th PREVIOUS X NODE X ‘oddada g c PREVIOUS X (a) Before swapping g and x NODE Y с NODE Y X NODE X addgħa W (b) After swapping g and x Figure P6.10. Swapping of elements in a singly linked list by manipulating links iarrow_forward
- Create a computer programme to arrange objects in a stack so that the smallest ones are on top. Although you are allowed to utilise an extra temporary stack, you are not allowed to transfer the components into another data structure (such an array). The following operations are supported by the stack: push, pop, peek, and is Empty.arrow_forwardThis program will use an array implementation of a linked list to keep an ascending sorted list of numbers. The input data consists of two fields: a single character and an integer value. The single character gets interpreted as one of the following: A - represents a value that is to be added to the linked listD - represents a value to be deleted from the linked listP - indicates that all values are to be printed in ascending order The character is only used to determine which process is to be executed; it should not be printed, entered into the linked list, or processed in any way. The main program should be mainly function calls. Process input data until end of file. All output should be sent to an output file and be appropriately formatted and labeled. Keep a running log of everything that is going on in the processing. Input file: A 54A -17A 32 A 81 A -30 A 18 P A 41 A 93 A 65 A 80 A 104 A -20 D 81 D 54 D -30 A 79 A 63 A 77 A –33 D 104 D -20 D 80 D 32 Parrow_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
- 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