05 - 12A - Data Structure
05 - 12A - Data Structure
Data Structure is a way of organizing and storing data in such a manner so that it can be
accessed and work over it can be done efficiently and less resources are required. It define the
relationship between the data and the operations over those data. There are many various
types of data structures defined that make it easier for the computer programmer, to
concentrate on the main problems rather than getting lost in the details of data description and
access.
List
List is a collection of elements/items and each item has its own index value. Index of first item is 0
and the last item is n-1. Here n is number of elements/items in a list.
Creating a list Lists are enclosed in square brackets [ ] and each item is separated by a comma.
e.g.
list1 = [20,30,40,50 ];
list2 = ["aarani", "burfi", "chittoor"];
list3 = [‘CPU', ‘Mouse', 8750, 600];
Stack
A stack is a linear data structure in which all the insertion and deletion of data / values are done at
one end only.
It is type of linear data structure.
It follows LIFO(Last In First Out) property.
Insertion / Deletion in stack can only be done from top.
Insertion in stack is also known as a PUSH operation.
Deletion from stack is also known as POP operation in stack.
Peak: Peak refers to the inspection of stack’s top most value without removing it. Sometime this is
also called as inspection.
Underflow: This refers to a situation when one tries to pop/delete an item from an empty stack.
That is stack is currently having no item and still one tries pop an item.