Features of Data Structure ‘Stack’
- ‘To Stack’ means ‘To Pile’.
- Stack is a linear data structure – it is linear in the vertical.
- It represents a linear collection which is visualized in the vertical.
- Size of the collection represented by stack is known either before or during runtime.
- Each of the two size related specifications of stack has a different kind of software implementation.
- Collection represented by stack is implemented using array as a tool if the size of its collection is known before run time.
- Collection represented by stack is implemented using linked list as a tool if the size of its collection is known during run time.
- Each tool of implementation of stack has its own implementation related requirement.
- Implementation requirement for array is an index variable.
- Implementation requirement of a linked list is a pointer member.
- End where the collection represented by stack begins is called ‘Bottom of Stack’.
- End where collection represented by stack ends is called ‘Top of Stack’.
- Collection represented by stack goes from bottom to top of stack.
- Stack is a non recursive data structure.
- Bottom end of the stack is fixed.
- Top end of the stack is operational.
- Process of adding a node in the collection represented by stack is called ‘PUSH’ operation.
- During PUSH process, only one value is added in the collection at a time.
- Process of deleting a node from the collection represented by stack is called ‘POP’ operation.
- Node PUSH-ed last is POP-ed first. Stack follows LIFO (Last In First Out) protocols in both PUSH and POP processes and in the implementations of its both size related specifications.
- During POP process, only one value is deleted from the collection at a time.
- Both PUSH and POP operate at the end representing top of the stack.
- From PUSH and POP, only one operation takes place at one time.
- With each PUSH operation, size of collection represented by stack increases by one.
- With each POP operation, size of collection represented by stack decreases by one.
- POP has a precondition in the implementation of both kinds of specifications of stack.
- PUSH has a precondition in the implementation of that specification of stack in which the size of the collection represented by stack is known before run time.
- Valid address allocation is the precondition in that specification of stack in which the size of the collection represented by stack is known during run time.
- Stack is classified as ‘Static Stack’ if the size of its collection is known before run time.
- Stack is classified as ‘Dynamic Stack’ if the size of its collection is known during run time.
- Node through which we access collection represented by a stack is called ‘Representative Node’ of stack.
- Node representing top of the stack is the ‘Representative Node’ of its collection.
- Top of the stack moves away from the bottom of the stack after each PUSH process.
- Top of the stack moves towards from the bottom of the stack after each POP process.
- Top of the stack oscillates during successive PUSH and POP processes.
All the Stack points taken from my Sir’s Notes. All credit to him.
What is Stack?
A common question asked to any programmer during any interview or viva. Just remember a few points of these and you are through. 😀
Happy Programming… 🙂
- Computer Algorithms: Stack and Queue (stoimen.com)
- C++ Push to stack using assignment operator? (daniweb.com)
- Linked Implementation of a Stack (sourcecode4all.wordpress.com)
- Python Lists – push and pop simultaneously without risk?? (daniweb.com)
What is a Data Structure???
- A DS Represents a finite collection of data.
- Size of the collection is known before execution i.e static DS & is fixed e.g-Arrays
- Size of the collection will be known during execution i.e variable or dynamic DS e.g-Linked List
- It demonstrates relationship among the members- fits collection
- It has methods to process members. i.e addition, deletion- fits collection
The entire triplet is called a Data Structure.
Example of Data Structures are Stack, Queue, Linked List, Trees, Arrays, Files etc.
Simple Definition for anyone to understand. I suggest every one to explore this topic more and more to become a good programmer.
- New course: Algorithms and Data Structures – Part 2 (pluralsight.com)
A system call is a request for a service that a program makes to the kernel.
The service is generally something that only the kernel has the privilege to do, such as doing I/O, creating and executing new processes, scheduling etc.