Introduction to Data Structure
- We can use data structure depending upon our areas of application.
- A data structure can be simple or complex.
- These kinds of data structures are known as Fundamentals data structure or Classic data structure.
- There are two kinds of classic data structure.
- Linear.
- Non-Linear.
- The Linear data structure can be categories as:
- Array
- Linked List
- Queue
- Stack
- The non-linear data structure can be categories as:
- Files
- Tables
- Tree
- Graph
Stacks
- Stack is a linear data structure.
- It is very useful for various applications for computer science.
- Example: Shunting train in railway yards
- Example: Shipment in cargo
- Example: Plates on a tray
- Example: Stacks of coins
- Example: Stacks of drawers
- The strategy to store and retrieve in stack data structure is LIFO.
- LIFO stands for Last In First Out.
- The stack data structure has the following kinds of characteristics:
- It is an ordered collection.
- It has homogeneous data elements.
- It can insert or delete elements.
- The insertion and deletion take place at one end only
- The insertion operation in stack called a PUSH.
- The deletion operation in stack called a POP.
- The PUSH & POP operations performed on the position of the stack are called TOP of the stack.
- The elements of the stack are called an ITEM.
- The maximum number of elements is considering as SIZE.
- Sometimes, a stack may face two different kinds of errors.
- Underflow: when POP operations performed and stack is empty.
SIZE = 5 and POP operations
SIZE = 5 & PUSH operations
Representation of STACK
- You can implement STACK using any computer programming language.
- We can implement STACK using various ways:
- Using One Dimension array
- Using Single Linked List
Operations on STACK
Tags:
data structure