C++
Using the Stack operations, write a pseudocode routine, dupA, that
takes aStack for string, checks to see if the top starts with ‘A’
or ‘a’. If so, duplicate the top of the stack (i.e. push a copy of
that value onto the stack) else if length > 10, pop it off the
stack
C++ implentation of above problem is in following screenshot:


Here the output:
if TOS(top of stack) = a

if TOS= A

if stack length > 10

if no condition is matched

Here is the code:
#include <iostream>
#include <stack>
using namespace std;
stack<char> st; // Global stack variable
void display() // Stack display function
{ while (!st.empty()) {
cout<< st.top()<<"\n";
st.pop();
}
}
int main() {
string name; // user input
string
cout<<"Enter any String: ";
cin>>name;
for(int i=0;i<name.size();i++) // pushing the
elements into stack
st.push(name[i]);
if(st.top()=='A' || st.top()=='a') // condition
checking for A or a
{
cout<<"TOP of
Stack: "<<st.top()<<"\n";
st.push(st.top());
cout<<"Duplicating
the TOP of Stack....\n";
cout<<"Stack
elements are: \n";
display();
}
else if (st.size()>10) // condition checking
for stack length
{
cout<<"Stack
length is: "<<st.size()<<"\n";
cout<<"Stack
elements are: \n";
display();
}
else {cout<<"Stack elements are:
\n";
display();}
}
C++ Using the Stack operations, write a pseudocode routine, dupA, that takes aStack for string, checks...
Need help. write a C program stack-ptr.c that implements a stack using a link list. Below is a skeleton code to start with.Jjust edit to make thread friendly. examplpe: push(5, &top); push(10, &top); push(15, &top); int value = pop(&top); value = pop(&top); value = pop(&top); this program currently has a race condition. use Pthread mutex locks to fix the race conditions. test you now thread safe stack by creating 200 concurrent threads in main() that push and pop values. -use...
(Data Structure) Using only emptyCheck(), peek(), push(a), and pop() operations, write a function Middle(Stack S) that returns the value from stack S that is in the middle, (i.e., location [size / 2]). You may create additional stacks as needed, but S must be restored by the end of the routine.
Suppose we execute the following stack operations on a stack of ints. push(1); pop(); // #1 push(10); pop(); // #2 push(7); push(4); push(3); pop(); // #3 push(5); pop(); //#4 Write the final state of the stack, and for each pop() operation, write the value that will be popped off the stack (pops are numbered so you can refer to them).
Java Write a pseudocode and Java program to implement the Stack using arrays. Write Push(), Pop(),and Display() methods to demonstrate that it works.
Stacks There are two main operations associated with stacks; 1) putting things on the stack which is referred to as push, 2) taking things from the stack which is referred to as pop. We can create a stack using linked lists if we force ourselves to insert and remove nodes only at the top of the list. One use of a stack is when you want to write a word backward. In that case, you will read the letters of...
Using either a Stack or Queue, write a C++ program that uses a for loop to push or enqueue 100 integers (values of 1-100) onto a stack or queue. Afterwards, the program should pop or dequeue these values off the stack or queue and write them to one of two textfiles (int.txt and int2.txt) based on whether a value is even or odd. If the popped or dequeued value is even, then that particular value should be written into int2.txt....
Create a C++ program. Include comment, input and output
file.
STACK IMPLEMENTATION USING AN link
list
IMPLEMENT THE FOLLOWING STACK OPERATIONS using a
TEMPLATED CLASS.
WRITE ALL THE FULL-FUNCTION DEFINITIONS NEEDED for the
OPERATIONS.
OUTPUT: PRINT ALL THE ELEMENTS ON THE STACK.
Stack Operations initializestack: Initializes the stack to an empty state. isEmptyStack: Determines whether the stack is empty. If the stack is empty, it returns the value true; otherwise, it returns the value false. isFul1stack: Determines whether the stack...
Dynamic Implementation of Stack - The purpose is to use our dynamic implementation of stack. The application will be to add large numbers. Review adding large numbers Remember that we can use stacks to safely add integer values that overflow the int data type g. in Java, the maximum possible int value Integer.MAX_VALUE is: 2147483647 so any int addition larger than this will overflow and fail Using stacks to add large numbers safely Will actually represent the large integers to...
Python: using a stack, implement a function that takes in an arithmetic expression, and evaluates it, supported operations are + and -, which have same precedence. Note: one way to do it is to scan the entire expr pushing numbers onto val-stack and operations on op-stack until tokens in expr are done. Then, use a loop to pop two numbers from val-stack and one operation from op-stack, evaluate, and push results back to val-stack, until op-stack is empty.
Write a program that uses a stack to reverse its inputs. Your
stack must be generic and you must demonstrate that it accepts both
String and Integer types. Your stack must implement the following
methods:
push,
pop,
isEmpty (returns true if the stack is empty and false
otherwise), and
size (returns an integer value for the number of items in the
stack).
You may use either an ArrayList or a LinkedList to implement
your stack. Also, your pop method must...