Chapter-6 Data Structures (Notes)
Chapter-6 Data Structures (Notes)
Difference b/w:
DATA TYPE DATA STRUCTURE
It defines the type of values we can store and The physical implementation that defines storing,
operate on. accessing and manipulation of data stored in it.
Values can directly be assigned to the data type Has specififc insertion and deletion
variables
Can hold values and not data, so it is data less Can hold different kind and types of data within one
single object
e.g.- int, float, etc e.g.- stacks, queues, etc
STACK
Stack is a linear sequence structure or a list of elements in which insertion and deleting can take
place only at the end.
• It is a dynamic data structure (it grows and shrinks).
• An empty stack is known as UNDERFLOW.
• A stack filled to it's specified capacity is known as OVERFLOW.
Major Operations:
1. Push
When we work with a fixed size stack, insertion in it results into an 'overflow' situation.
3. isEmpty()
When we work with an empty stack, deletion in it results into an 'underflow' situation.
Implementation using a List:
CREATING
PUSH
POP
TRAVERSING
Applications:
1. Real-life
a. Pile of clothes
b. Stack of dishes
c. Bangles on a wrist
2. Program based
a. Reversing a word/line
b. To store previous state of program when fun() is called or during recursion
c. Backtracking (form of recursion)
d. Undo Mechanism