A stack is a linear data structure that follows a particular order in which the operations are performed. The order may be LIFO(Last In First Out) or FILO(First In Last Out). Consider an example of plates stacked over one another in the canteen. The plate which is at the top is the first one to be removed, i.e. the plate which has been placed at the bottommost position remains in the stack for the longest period.
Mainly the following two basic operations are performed in the stack:
Program code:
Output:
[8, 4, 5, 6, 7] [4, 5, 6, 7]
In the above code snippet basic functions of stack are demonstrated.
To view all the lessons in chapter 10: http://computertutor.in/class-12-computer-science/chapter-10/
To view entire class 12 computer science study material: http://computertutor.in/resources/
You cannot copy content of this page