Question

Implement the stack queue data structure with a linked list implementation to get the given test...

Implement the stack queue data structure with a linked list implementation to get the given test code in driver.cpp to work properly:

driver.cpp code:

#include <iostream>
#include "stackLL.h"

using namespace std;

int main()
{
        /////////////Test code for stack ///////////////
        stackLL stk;

        stk.push(5);
        stk.push(13);
        stk.push(7);
        stk.push(3);
        stk.push(2);
        stk.push(11);

        cout << "Popping: " << stk.pop() << endl;
        cout << "Popping: " << stk.pop() << endl;

        stk.push(17);
        stk.push(19);
        stk.push(23);

        while( ! stk.empty() )
        {
                cout << "Popping: " << stk.pop() << endl;
        }
        
        // output order: 11,2,23,19,17,3,7,13,5

}

stackLL.h code

class stackLL
{
private:
        class node
        {
        public:
                //put what you need in here
        };

        node * top;

public:
        
        stackLL()
        {}

        ~stackLL()
        {}

        //return true if empty, false if not
        bool empty()
        {}

        //add item to top of stack
        void push(int x)
        {}

        //remove and return top item from stack
        int pop()
        {}

};

Also provide a big-Oh bound on the worst case run-time for that method in terms of the number of items ‘n’ contained in the data structure at the time of the method call.  Justify your bound in each case.

Thank you

0 0
Add a comment Improve this question Transcribed image text
Request Professional Answer

Request Answer!

We need at least 10 more requests to produce the answer.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the answer will be notified once they are available.
Know the answer?
Add Answer to:
Implement the stack queue data structure with a linked list implementation to get the given test...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
  • In C++ Implement a queue data structure using two stacks. Remember a queue has enqueue and...

    In C++ Implement a queue data structure using two stacks. Remember a queue has enqueue and dequeue functions. You could use either the array or linked list implementation for stacks and queues. Source for stack array: --------------------------------------------------- #include<iostream> #define SIZE 100 #define NO_ELEMENT -999999 using namespace std; class Stack { int arr[SIZE]; // array to store Stack elements int top; public: Stack() { top = -1; } void push(int); // push an element into Stack int pop(); // pop the...

  • I have a queue and stack class program that deals with a palindrome, I need someone...

    I have a queue and stack class program that deals with a palindrome, I need someone to help to put in templates then rerun the code. I'd greatly appreciate it. It's in C++. Here is my program: #include<iostream> #include<list> #include<iterator> #include<string> using namespace std; class Queue { public: list <char> queue; Queue() { list <char> queue; } void Push(char item) { queue.push_back(item); } char pop() { char first = queue.front(); queue.pop_front(); return first; } bool is_empty() { if(queue.empty()) { return...

  • Convert following code to implement linked list C++ language #include<iostream> using namespace std; int top =...

    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...

  • in c++ please include all of the following " template class, template function, singly linked list,...

    in c++ please include all of the following " template class, template function, singly linked list, the ADT stack, copy constructor, operator overloading, "try catch"and pointers Modify the code named "Stack using a Singly Linked List" to make the ADT Stack that is a template class has the code of the destructor in which each node is directly deleted without using any member function. As each node is deleted, the destructor displays the address of the node that is being...

  • #include <iostream> #include <stack> #include <queue> using namespace std; void printFromStack(string expr){ stack<char> myStack; for(int i=0;...

    #include <iostream> #include <stack> #include <queue> using namespace std; void printFromStack(string expr){ stack<char> myStack; for(int i=0; i<expr.length(); i++){ //Insert code here to push each character onto the stack } cout << "My stack is popped in this order" << endl; while(!myStack.empty()){ //Insert code here to cout the top of the stack one by one //Pop each one after it’s printed out } cout << endl; } void printFromQueue(string expr){ queue<char> myQueue; //Insert code here to push each character onto the...

  • 1. (40’) In myStack.cpp, implement the member functions of the class myStack, which is the class...

    1. (40’) In myStack.cpp, implement the member functions of the class myStack, which is the class for integer stacks. 2. (20’) In stackTest.cpp, complete the implementation of function postfixTest(), which use an integer stack to evaluate post-fix expressions. For simplicity, you can assume the post-fix expression is input character by character (i.e., not an entire string), and each operand is a non-negative, single-digit integer (i.e., 0,1,…,9). However, you are supposed to detect invalid/ illegal post-fix expression input, e.g., “4 5...

  • PART A - STACKS To complete this assignment: Please study the code posted below. Please rewrite...

    PART A - STACKS To complete this assignment: Please study the code posted below. Please rewrite the code implementing a template class using a linked list instead of an array. Note: The functionality should remain the same *************************************************************************************************************** /** * Stack implementation using array in C/procedural language. */ #include <iostream> #include <cstdio> #include <cstdlib> //#include <climits> // For INT_MIN #define SIZE 100 using namespace std; /// Create a stack with capacity of 100 elements int stack[SIZE]; /// Initially stack is...

  • Review the Stack implementation with Vector, and implement/answer the following methods. Stack One of the principles...

    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...

  • HI USING C++ CAN YOU PLEASE PROGRAM THIS ASSIGNMENT AND ADD COMMENTS: stackARRAY: #include<iostream> #define SIZE...

    HI USING C++ CAN YOU PLEASE PROGRAM THIS ASSIGNMENT AND ADD COMMENTS: stackARRAY: #include<iostream> #define SIZE 100 #define NO_ELEMENT -999999 using namespace std; class Stack { int arr[SIZE]; // array to store Stack elements int top; public: Stack() { top = -1; } void push(int); // push an element into Stack int pop(); // pop the top element from Stack int topElement(); // get the top element void display(); // display Stack elements from top to bottom }; void Stack...

  • can someone please fix this error in the stack file at line 18 ( class Stack2:public...

    can someone please fix this error in the stack file at line 18 ( class Stack2:public Stack { ) this is thew error ----> expected class name before '{' token Queue.h --> #include "Stack.hpp" template <typename ITEM> class Queue { private: ITEM item; Stack <ITEM> * s1= new Stack<ITEM>; Stack <ITEM> * s2= new Stack<ITEM>; public: Queue(){}; bool enqueue (ITEM item); bool dequeue (ITEM &item); bool check = true; ~Queue(); }; //this is the class which contains the functions of...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT