0% found this document useful (0 votes)
9 views

12 - Revision-III-UNIT-I Computational Thinking and Programming - 2

Uploaded by

plschange3
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)
9 views

12 - Revision-III-UNIT-I Computational Thinking and Programming - 2

Uploaded by

plschange3
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/ 2

Revision –III

UNIT-I Computational Thinking and Programming - 2

Data Structures
Data Structures: Stack using List

Data Structure

In Data Structure w e a r e collecting and organizing data in such a way that wecan perform
operations on these data in an effective way.

Stack

A stack is a data structure whose elements are accessed according to the Last- In First-
Out (LIFO) mechanism. This is because in a stack, insertion and deletion of elements can
only take place at one end, which is called top of the stack.

Consider the following examples of stacks:


1. A pile of books
2. A stack of coins
3. Ten glass plates placed one above another.

Fig.1 A stack of coins (ref: google.com)

In the above picture coins are kept one above the other and if any additional coinI need to be
added, it can be added only on the top.

Similarly, If we want to remove any coin from the stack, the coin on the top of the stack has to
be removed first. That means, the coin that was kept last (i.e. at the top) in the stack has to
be taken out first.
The two operations performed on the stack are:

 Push operation: It means inserting element at the top of the stack. Thiscan be
done with the help of append() method of the list as: st.append(element) where ‘st’ is
a list.
 Pop operation: It means removing the topmost element from the stack. This can be performed
using pop() method of the list as: st.pop() where ‘st’is a list. This method returns the removed
element that can be displayed.

You might also like