Profile PictureTop Solutions Stop!

C++ Stacks Part 1

$9.99
0 ratings

Stacks Part 1 _ Implementing an integer stack class using a vector Directions
A stack is a First in First Out
(FIFO) data structure.There are 4 primary operations on a stack:Push - Add an item to the stack in the top position
Pop - Remove an item from the top of the stack and return its value
STL doesn't return the value it just removes it so this is a difference here.
Top - Return the top most item of a stack.
Empty - Returns true if the stack is empty, false otherwise.
To implement this, you need to create a class implementing the above information. You must use a vector as your underlying data
store.You may NOT use STL stacks in this example.
You must create a driver program to test the above functions
Write a driver program testing the
stack.Here is an example of some operations on a stack. Values represents the values on the stack.Stack X -> Values()IsEmpty -> Returns True -> Values()
Push(5) -> Returns Void -> Values(5)
Push(6) -> Returns Void -> Values(6, 5)
Push(23) -> Returns Void -> Values(23, 6, 5)
Pop -> Returns 23 -> Values(6, 5)
Top -> Returns 6 -> Values(6,5)
Pop -> Returns 6 -> Values(5)
IsEmpty -> Returns FALSE -> Values(5)
Push(12) -> Returns Void -> Values(12, 5)
Tips **You want to avoid having to shift the vector constantly.
One way to do this is to have your stack grow DOWN instead of UP (Highest to lowest). (picture the vector vertically)

Add to cart
Size
435 Bytes
Copy product URL
$9.99

C++ Stacks Part 1

0 ratings
Add to cart