Question: Design and implement a dynamic linked stack (LIFO last-in, first-out) using C++ classes including the following methods: o isEmpty ( ) - returns an integer
Design and implement a dynamic linked stack (LIFO last-in, first-out) using C++ classes including the following methods:
o isEmpty ( ) - returns an integer or enumerated bool type; true for an empty stack, false for non-empty stack
o push ( ) - allocates a node dynamically; initializes it to the data passed in; inserts the node at the top of the stack only; returns true or false for successful or unsuccessful insertion, respectively
o pop ( ) - de-allocates a node at the top of the stack dynamically; returns true if node was de-allocated, false otherwise; NOTE: some variations of pop ( ) will return the data in the node found at the top of the stack, instead of true or false
o top ( ) or peek ( ) returns the data found in the top node of the stack; nodes are not affected (removed)
o printStack ( ) - prints out the data in each node of the stack; may be printed iteratively or recursively
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
