Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Exercise A ( in c++ ) Use a linked list to implement a stack. The stack should store characters. The stack should support the following

Exercise A

(in c++) Use a linked list to implement a stack. The stack should store characters. The stack should support the following operations/functions:-

1. push:- adds a new element to the top of the stack. Push should take a character as an argument (the character to be pushed onto the stack).

2. pop:- removes an element from the top of the stack. Pop should return a character. (the character popped off the stack. If the stack is empty when pop is called it should return the null character.).

3. empty:- returns a true or false value depending on whether the stack is empty of not.

To test the stack code push the following characters onto the stack t, e, s, t, a, n, g. Pop three characters off the stack. Then push the characters i, n, g onto the stack. Finally pop all of the remaining characters off the stack and print them in the order they are popped. You should use a loop, using the empty operation as part of the stopping condition, to pop and print the stack.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases Illuminated

Authors: Catherine M. Ricardo, Susan D. Urban, Karen C. Davis

4th Edition

1284231585, 978-1284231588

More Books

Students also viewed these Databases questions