Stack:
Stacks are a type of container with LIFO (Last In First Out) type of working, where a new element is added at one end and (top) an element is removed from that end only. Your Stack should not be of the fixed sized. It should be able to grow itself.
boolempty(): Returns whether theStackis empty or not. Time Complexity should be: O(1)
boolfull():Returns whether theStackis full or not. Time Complexity should be: O(1)intsize(): Returns the current size of theStack. Time Complexity should be: O(1)Typetop (): Returns the last element of theStack.Time Complexity should be: O(1)
voidpush(Type): Adds the element of type Type at the top of the stack. Time Complexity should be: O(1)
Typepop(): Deletes the top most element of the stack and returns it. Time Complexity should be: O(1)
Now write a global function show stack which should display all the contents of the stack.
void showStack(Stack s);Instantiate several objects of Stack, test all the functions of Stack on them and then display them through showStack function.Program in C++.compile on visual studio.
Instantiate several objects of Stack, test all the functions of Stack on them and then display them through showStack function.
Program in C++.
compile on visual studio.
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here