Starting Out with C++ from Control Structures to Objects (9th Edition)
9th Edition
ISBN: 9780134443850
Author: GADDIS
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Expert Solution & Answer
Chapter 19, Problem 13RQE
Program Description Answer
The item which is inserted “last” is retrieved first.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
C++ ProgrammingTopic: Stack, Ques and DequesBelow is the initial program of the main file, only modify the main file, sllstack file also provided. See attached photo for instructions.
main.cpp
#include <iostream>
#include <cstring>
#include "sllstack.h"
using namespace std;
int main(int argc, char** argv) {
SLLStack* stack = new SLLStack();
int test;
string str;
cin >> test;
switch (test) {
case 0:
getline(cin, str);
// PERFORM SOLUTION TO BRACKETS PROBLEM HERE
// FYI: Place your variable declarations, if any, before switch.
break;
case 1:
stack->push('a');
stack->push('b');
stack->push('c');
cout << stack->pop() << endl;
cout << stack->pop() << endl;
cout << stack->pop() << endl;
cout << stack->isEmpty() << endl;
break;…
Stacks
1- Write a Python function that takes a user input of a word and returns True if it is a Palindrome and returns False otherwise (Your function should use a Stack data structure). A palindrome is a word that can be read the same backward as forward. Some examples of palindromic words are noon, civic, radar, level, rotor, kayak, reviver, racecar, redder, madam, and refer.
2- Write a Python function that takes a stack of integer numbers and returns the maximum value of the numbers in the stack. The stack should have the same numbers before and after calling the function.
3- Write a main function that tests the functions you wrote in 1 and 2 above and make sure that your code is well documented.
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.
public void ReverseStack(){
}
Chapter 19 Solutions
Starting Out with C++ from Control Structures to Objects (9th Edition)
Ch. 19.1 - Describe what LIFO means.Ch. 19.1 - What is the difference between static and dynamic...Ch. 19.1 - What are the two primary stack operations?...Ch. 19.1 - What STL types does the STL stack container adapt?Ch. 19 - Prob. 1RQECh. 19 - Prob. 2RQECh. 19 - What is the difference between a static stack and...Ch. 19 - Prob. 4RQECh. 19 - Prob. 5RQECh. 19 - The STL stack is considered a container adapter....
Ch. 19 - What types may the STL stack be based on? By...Ch. 19 - Prob. 8RQECh. 19 - Prob. 9RQECh. 19 - Prob. 10RQECh. 19 - Prob. 11RQECh. 19 - Prob. 12RQECh. 19 - Prob. 13RQECh. 19 - Prob. 14RQECh. 19 - Prob. 15RQECh. 19 - Prob. 16RQECh. 19 - The STL stack container is an adapter for the...Ch. 19 - Prob. 18RQECh. 19 - Prob. 19RQECh. 19 - Prob. 20RQECh. 19 - Prob. 21RQECh. 19 - Prob. 22RQECh. 19 - Prob. 23RQECh. 19 - Prob. 24RQECh. 19 - Prob. 25RQECh. 19 - Prob. 26RQECh. 19 - Write two different code segments that may be used...Ch. 19 - Prob. 28RQECh. 19 - Prob. 29RQECh. 19 - Prob. 30RQECh. 19 - Prob. 31RQECh. 19 - Prob. 32RQECh. 19 - Prob. 1PCCh. 19 - Prob. 2PCCh. 19 - Prob. 3PCCh. 19 - Prob. 4PCCh. 19 - Prob. 5PCCh. 19 - Dynamic String Stack Design a class that stores...Ch. 19 - Prob. 7PCCh. 19 - Prob. 8PCCh. 19 - Prob. 9PCCh. 19 - Prob. 10PCCh. 19 - Prob. 11PCCh. 19 - Inventory Bin Stack Design an inventory class that...Ch. 19 - Prob. 13PCCh. 19 - Prob. 14PCCh. 19 - Prob. 15PC
Knowledge Booster
Similar questions
- C++ Please help me modify this coding which need to apply a linked list to store the node. Also use a stack concept. The code: #include<iostream>#include<stdlib.h>#include<string.h> using namespace std; struct node{ char data[100]; struct node* next; }; int words = 0; // function for add values to stackstruct node* add(struct node* stack, char *str){ struct node* tp = (struct node*)malloc(sizeof(struct node)); strcpy(tp->data,str); tp->next = stack; words++; return tp; } //redo functionvoid redo(struct node* stack){ if(stack == NULL) return; words++; } //undo functionvoid undo(struct node* stack){ if(stack == NULL) return; words--; } //print functionint print(struct node* stack,int idx){ if(stack == NULL) return 0; idx = print(stack->next,idx); if(idx<words) cout<<"\n"<<stack->data; return idx+1; } //function for save in fileint save_words(FILE* filePointer, struct node*…arrow_forwardC# 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. private int [] stack; private int size; public void ReverseStack(){ }arrow_forwardstruct Faculty { int id; char name[30]; char status[10]; //status permanent or visiting Faculty next; }; Assume we have three stacks S, V and P. S is a stack having mix data of visiting and permanent faculty members, V is empty and for visiting faculty memebrs and P is also empty for permanent faculty members. Using primitive functions of stack write a C++ code which reads entire data from S and write on respective stack V or P.arrow_forward
- hello everyone I was hoping to get this question responded step by step and how to ... (please) ( a really good explanation because I'm really iffy on it ) language: c++ how do I create a stack that supports multiply (mult), divide (div), addAll, and multAll operations. and outputs the following Please type answer no write by hend.arrow_forwardCompulsory Task Follow these steps: ● For this task, you are required to refactor the badly written program RPN.java. This program is a Reverse-Polish Notation calculator which uses a stack. A Reverse-Polish Notation calculator is a calculator that will calculate equations where the operator follows the operands. Therefore, instead of inputting an equation as “1 + 2”, a Reverse-Polish Notation calculator would take the following input “ 1 2 +”. A stack is a data structure in which items are added to the top of the stack and removed from the top of the stack. It is therefore known as a last-in, first-out (LIFO) data structure. Stack terminology: ○ Push — is an operation that adds an item to the top of a stack. ○ Pop — is an operation that removes an item from the top of a stack. The pseudocode for this program is: ○ Get an equation (e.g. 2 3 +) from the user as input. ○ Loop through the string value input by the user. ■ When you encounter a number (remember that numbers can include…arrow_forwardWhat will be the stack content after following operations: Push 5 Push 8 Pop Push 1 Push 12 Poparrow_forward
- True or False For each statement below, indicate whether you think it is True or False. If you like, you can provide a description of your answer for partial credit in case you are incorrect. Given a stack implemented as an array, and the following functions performed: Push(A), Push (B), Push(C), Pop(), Push(D), Push(E), Pop(), Push(F) The array will be [A][B][D][F] and the “top” of the stack will be at index 3 where [F] is The next element that will be removed when Pop is called will be A If we Push(G), [G] will be inserted at index 0 Given a queue implemented as an array with a maximum capacity of 5 elements and O(1) insert and remove, and the following functions are performed: Insert(7), Insert(6), Insert(5), Insert(4), Remove(), Remove(), Insert(3), Insert(2), Insert(1), Remove() The removeIndex value will be index 4 The array will be [2][1][ ][4][3] The insertIndex value will be index 2 Given a priority queue implemented as a standard linked list with only a…arrow_forwardPLEASE NAME AND SEPERATE THE 3 FILES CORRECTLY: Implement a program in C++ that has the following three parts and each does the following: Implements in C++ a Stack ADT (save the file as StackADT.h) Implements all the necessary methods (behavior) of a Stack (save the file as StackADT.cpp) Implements in C++ a main function (the client or application program) that creates and uses Stack objects (save the file as StackMain.cpp). This main function should be able to do the following: It should be able to read a given text file as input, It should be able to get each input value from the input file (one word at a time) and store it (push) on the Stack object until it stores all the words from the input file. It should be able to retrieve an item from the stack and display it on the screen, and then delete (pop) that item from the stack, and repeat until it retrieves all the items from the stack object. NOTE: Please make sure you debug, run, test and see the program working…arrow_forwardHi please help me thankyou so much FILE: Stack.hGiven the Stack.h above and the following data is to be entered by a user:{ 83, 84, 65, 82, 71, 78, 79, 67 }Write a main program that uses Stack.h library to perform the following pseudo-code:1. create stack S1 and stack S2 as character2. start loop 8 times3.accept data from user4.if the data entered is odd number5.push into S16.else if the data entered is even number7.8. end loop9. display top S1push into S210. pop S111. start loop S2 is not empty12.display top S113.pop S114.display top S215.pop S216. end loop17. display top S118. роp S1arrow_forward
- C++ The List class represents a linked list of dynamically allocated elements. The list has only one member variable head which is a pointer that leads to the first element. See the following code for the destructor to List. ~ List () { for (int i = 0; i <size (); i ++) { pop_back (); } } What problems does the destructor have? Select one or more options: 1. There are no parameters for the destructor. 2. The return value from pop_back (if any) is nerver handled. 3. The destructor will create a stack overflow. 4. The destructor will create dangling pointers. 5.The destructor will create memory leaks. 6.The destructor will create undefined behavior (equivalent to zero pointer exception). 7.The condition must be: i <size () - 1 8. There is at least one problem with the destructor, but none of the above.arrow_forwardstruct node{ int a; struct node * nextptr; }; Write two functions. One for inserting new values to a link list that uses the given node structure. void insert(struct node **head, int value); Second function is called to count the number of even numbers in the link list. It returns an integer that represents the number of even numbers. int countEvenNumbers(struct node *head); Write a C program that reads a number of integers from the user and insert those integers into a link list (use insert function). Later pass the head pointer of this link list to a function called countEvenNumbers. This function counts and returns the number of even numbers in the list. The returned value will be printed on the screen. Note 1: Do not modify the function prototypes. Sample Input1: Sample Output1: 45 23 44 12 37 98 33 35 -1 3 Sample Input2: Sample Output2: 11 33 44 21 22 99 123 122 124 77 -1 4arrow_forwardFor this code just explain the void pop function, with enough explanation that how it is working. Also explain on the usage of pointer in this function. Thanks #include<iostream> using namespace std; int choice, j=0;int stack[50];int *top;bool Exit_Indicator = false; void displayStack() { cout << "\n\t~Stack Display~\nTOP ->"; for (int i = j-1; i >= 0; i--) cout << "\t|\t" << stack[i] << "\t|" << endl; cout << "\t-----------------";} void push(int i){ cout << "\n(" << i << ") has been PUSHED into the stack!"; *top = i; top++; j++;} void pop(){ if((*(top-2) != 0 && *(top-1)!= 0) || (*(top-2) == 0 && *(top-1)!= 0)) { cout << "\n(" << *(top-1) << ") has been POPPED from the stack!"; *(top-1)= 0; top--; j--; } else{ cout<<"\nTHE STACK IS EMPTY";}} int main() { int value; top = stack; do { cout <<…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning