
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.
#include <iostream>
#include <string>
using namespace std;
template <typename T>
class Stack {
private:
T stackArray[100];
int top;
public:
Stack() {
top = -1;
}
void push(T value) {
++top;
stackArray[top] = value;
}
bool isFullStack( ){
if(top == 100)
return true ;
else return false ;
}
void display() {
for(int i = 0; i <= top ; ++i) {
cout << stackArray[i] << " ";
}
cout << endl;
}
T pop() {
// check if the stack is not empty
if(isEmptyStack()) {
cout << "The stack is empty so you cannot pop element " << endl;
}
else {
T retVal = stackArray[top];
--top;
return retVal;
}}
T top_element() {
if( top != -1 )
return stackArray[top];
else
cout<< "Stack is empty "<< endl;
}
int count() {
return top + 1;
}
bool isEmptyStack() {
if (top == -1) {
return true;
}
else {
return false;
}
}
};
int main()
{
Stack<double> data_double;
cout<< "when performing pop() operation on the empty stack : "<< endl ;
data_double.pop();
data_double.push(15);
data_double.push(25);
data_double.push(226);
data_double.push(32);
data_double.push(5);
data_double.push(52);
data_double.push(92);
cout<< " Display all elements of the stack:" << endl ;
data_double.display() ;
cout << "Top element is :" << data_double.top_element() << endl;
data_double.pop();
cout<<"Stack contents after single POP : " <<endl ;
data_double.display();
cout << "Top element is( after one pop() :" << data_double.top_element() << endl;
cout<< " The number of elements in the stack : " << data_double.count()<< endl ;
cout<< "Is stack full ? " ;
data_double.isFullStack() ? cout<< "yes " : cout<< "NO ";
return 0;
}

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 DE...
C++ functions using linked list A templated stack class that stores type T with the following public functions: template <class T> class Stack{ - void Push(T t) - adds t to the top of the stack - T Pop() - asserts that the stack is not empty then removes and returns the item at the top of the stack. };
Suppose we decide to add a new operation to our Stack ADT called sizeIs, which returns a value of primitive type int equal to the number of items on the stack. The method signature for sizeIS is public int sizeIs() a.) Write the code for sizeIs for the ArrayStack class b.) Write the code for sizeIs for the LinkedStack class (do not add any instance variables to the class; each time sizeIs is called you must "walk" through the stack...
In Java. What would the methods of this class look like?
StackADT.java
public interface StackADT<T>
{
/** Adds one element to the top of this stack.
* @param element element to be pushed onto stack
*/
public void push (T element);
/** Removes and returns the top element from this stack.
* @return T element removed from the top of the stack
*/
public T pop();
/** Returns without removing the top element of this
stack.
* @return T...
Review the Stack implementation with Vector, and
implement/answer the following methods.
Stack One of the principles of good programming is to reuse existing code whenever practical. If you can reuse existing code, you don't need to spend the time to rewrite it. Code used previously has also been debugged, and will likely contain fewer errors. One of the easiest ways to create a container is to leverage an existing data type to build a new abstraction. In this lesson we...
Convert following code to implement linked list C++ language #include<iostream> using namespace std; int top = -1; //globally defining the value of top, as the stack is empty void push(int stack[], int x, int n) { if (top == -1) //if top position is the last of posiition of stack,means stack is full { cout << "Stack is full Overflow condition"; } else { top = top + 1; //incrementing top position stack[top] = x; //inserting element on incremented position...
Complete the implementation of the LinkedStack class presented in Chapter 13. Specifically, complete the implementations of the peek, isEmpty, size, and toString methods. See Base_A06Q1.java for a starting place and a description of these methods. Here is the base given: /** * Write a description of the program here. * * @author Lewis et al., (your name) * @version (program version) */ import java.util.Iterator; public class Base_A06Q1 { /** * Program entry point for stack testing. * @param args Argument...
QUESTION: ADT stack: resizable array-based implementation for Ch4 programming problem 4 "maintain the stacks's top entry at the end of the array" at array index N-1 where the array is currently allocated to hold up to N entries. MAKE SURE YOU IMPLEMENT the functions: bool isEmpty() const; bool push(const ItemType& newEntry); bool pop(); in ArrayStackP4.cpp //FILE StackInterface.h #ifndef STACK_INTERFACE_ #define STACK_INTERFACE_ template<class ItemType> class StackInterface { public: /** Sees whether this stack is empty. @return True if the...
Given an array-based stack of integers, sort it largest to smallest using recursion. Do NOT use any loop constructs such as while, for and so on. Only use the following stack ADT functions in the recursion: IsEmpty Push Pop Top (note: doesn’t remove anything from the stack). Your program should read 10 integers into a stack from a file named input.txt (outputting them to the screen first) then implement the recursions. Use stacks only, no queues. The program should then...
Please Write Pseudocode or Python code!
Thanks!
P1. b) is the following:
W1. (6 marks) Write the pseudocode for removing and returning only the second element from the Stack. The top element of the Stack will remain the top element after this operation. You may assume that the Stack contains at least two items before this operation. (a) Write the algorithm as a provider implementing a Stack using a contiguous memory implementation. You can refer to the implementation given in...
I need help Writing a Python code!!! Implement an ordered list using doubly linked list Implement the following operations for an ordered list of integers ordered in ascending order using a doubly linked list. The “head” of the list be where the “smallest items are and let “tail” be where the largest items are. You may use whatever mechanism you like to keep track of the head and tail of the list. E.g. references or sentinel nodes. • OrderedList ()...