Part 2: Dynamic Stack In this part, you are going to design a dynamic stack of characters implemented as a linked list. Complete the code below as specified by the comments below. typedef char el_t; class Stack { private: struct StackNode { el_t element; StackNode *next; // letter in the node // Pointer to the next node } ; StackNode *top; // Pointer to the stack top public: // Constructor Stack() { top = nullptr; } // Destructor -Stack () ; // Stack operations void push (el_t); void pop (el t &); void getTop (el_t &) const; void displayAll () const; bool isEmpty() const; } ; // implement the public methods highlighted in bold here int main () { Stack s; el_t c; cout << " initial stack contents" << endl; s.displayAl1(); s.pop (c); s.push('a'); cout << endl << " stack contents after pushing a: << endl; s.displayAl1(); s.push( 'b'); cout << endl << " stack contents after pushing b: s.displayAl1(); << endl; s.push('c'); s.push('d'); s.push('e'); s.push ('f'); s.push ( 'g') ; cout << endl << " stack contents after pushing c-g: " << endl; s.displayAl1(); s.getTop(c); cout << endl << "top elment is " << c < endl; s.pop (c); cout << endl << c << endl; cout << endl << stack contents after popping one element: << endl; s.displayAll(); s.pop (c); cout << endl << " " << c << endl; popped element: " stack contents after popping another element: cout << endl << << endl; s.displayAl1(); s.pop(c); s.pop (c); if (!s.isEmpty()) { s.getTop(c); cout << endl << "top elment is " << c << endl; } s.pop (c); cout << endl << stack contents after popping 3 more elements: << endl; s.displayAl1(); s.pop(c); s.pop(c); s.push('a'); s.push( 'b'); cout << endl << " final stack contents << endl; s.displayAll(); return 0;
Part 2: Dynamic Stack In this part, you are going to design a dynamic stack of characters implemented as a linked list. Complete the code below as specified by the comments below. typedef char el_t; class Stack { private: struct StackNode { el_t element; StackNode *next; // letter in the node // Pointer to the next node } ; StackNode *top; // Pointer to the stack top public: // Constructor Stack() { top = nullptr; } // Destructor -Stack () ; // Stack operations void push (el_t); void pop (el t &); void getTop (el_t &) const; void displayAll () const; bool isEmpty() const; } ; // implement the public methods highlighted in bold here int main () { Stack s; el_t c; cout << " initial stack contents" << endl; s.displayAl1(); s.pop (c); s.push('a'); cout << endl << " stack contents after pushing a: << endl; s.displayAl1(); s.push( 'b'); cout << endl << " stack contents after pushing b: s.displayAl1(); << endl; s.push('c'); s.push('d'); s.push('e'); s.push ('f'); s.push ( 'g') ; cout << endl << " stack contents after pushing c-g: " << endl; s.displayAl1(); s.getTop(c); cout << endl << "top elment is " << c < endl; s.pop (c); cout << endl << c << endl; cout << endl << stack contents after popping one element: << endl; s.displayAll(); s.pop (c); cout << endl << " " << c << endl; popped element: " stack contents after popping another element: cout << endl << << endl; s.displayAl1(); s.pop(c); s.pop (c); if (!s.isEmpty()) { s.getTop(c); cout << endl << "top elment is " << c << endl; } s.pop (c); cout << endl << stack contents after popping 3 more elements: << endl; s.displayAl1(); s.pop(c); s.pop(c); s.push('a'); s.push( 'b'); cout << endl << " final stack contents << endl; s.displayAll(); return 0;
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
in c++ language please
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 2 steps
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education