0% found this document useful (0 votes)
20 views1 page

05 - 12A - Data Structure

Data structures organize and store data to allow for efficient access and manipulation. Common data structures include lists, stacks, and queues. Lists use indexes to store and access elements. Stacks follow LIFO ordering and only allow insertion and deletion from one end. Common stack operations are push to add and pop to remove elements.

Uploaded by

Tukaram P S
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views1 page

05 - 12A - Data Structure

Data structures organize and store data to allow for efficient access and manipulation. Common data structures include lists, stacks, and queues. Lists use indexes to store and access elements. Stacks follow LIFO ordering and only allow insertion and deletion from one end. Common stack operations are push to add and pop to remove elements.

Uploaded by

Tukaram P S
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

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.

Using List as Stack in Python:


The concept of Stack implementation is easy in Python, because it support inbuilt functions
(append() and pop()) for stack implementation. By Using these functions make the code short and
simple for stack implementation. To add an item to the top of the list, i.e., to push an item, we use
append() function and to pop out an element we use pop() function. These functions work quiet
efficiently and fast in end operations.

Peak: Peak refers to the inspection of stack’s top most value without removing it. Sometime this is
also called as inspection.

Overflow and under flow:


Overflow: This refers to a situation, when one tries to push an element in stack, that is full. In
Python, (for stacks and list implemented as list), since list can grow, ‘overflow’ condition does not
arise until all memory is exhausted.

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.

You might also like