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. So using the class made in task 1, make a class named asStack, having following additional functionalities:
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)
Program in C++.
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here