Professional Documents
Culture Documents
Data Structures Using C (CSIT 124) Module-2 Stack and Queues
Data Structures Using C (CSIT 124) Module-2 Stack and Queues
1
Amity School of Engineering and Technology
Contents :
Stack
Definition
Stack Representation
Array Representation
Linked List Representation
Operations on Stacks- Push & Pop
2
Amity School of Engineering and Technology
Learning Objectives
• Impart in-depth knowledge of data structure and its implementation
in computer programs.
• Make students understand the concepts of Stack linear data structure.
• Make students understand the applications of Stack.
3
Amity School of Engineering and Technology
Recommended Reading
Textbooks:
• Yashwant Kanetkar,”Data Structure using C”, BPB Publication, 5th Edition ,2011
• A.Tannenbaum,Y. Lanhgsam and A.J. Augenstein ,” Data Structures Using C And C++ “,Prentice Hall of
India,2nd Edition,2009.
• Jean-Paul Tremblay, P.G Sorenson, “An Introduction to Data Structures with applications”, Mcgraw-
Hill ,2nd Edition ,1984.
Reference Book:
• Robert L Kruse, “Data Structure and Program Design in C”, Prentice Hall (1991).
• Noel Kalicharan ,“Data Structure in C” ,Ist Edition Create space publisher, 2008.
• Mark Allen Weiss,“Data Structure and algorithm Analysis in C”,2nd Edition AddisonWesley,1996.
• E. Balagurusamy, “Problem Solving through C language”, TMH publication, Fourth Edition, 2008.
• R.S Salaria ,“Data Structures & Algorithms using C”,Khanna Publication,4th Edition,2009
• E.Horowitz and S.Sahni,”Fundamentals of Data Structures in C “,2nd Edition, Universities Press,2008.
4
Amity School of Engineering and Technology
Module Assessment
• Quiz (Conceptual and Numerical Based)
• Assignment
5
Amity School of Engineering and Technology
STACK
Definition: Stack is a linear data
structure that principally works on
the Last-in First-out (LIFO). The
element that is inserted first will be
out at last and vice-versa
Examples of Stack
6
Amity School of Engineering and Technology
STACK TERMINOLOGIES
1. Top of Stack: TOP is the pointer
that shows the position of the
topmost element of the stack.
2. MaxStack: MaxStack shows the
maximum size of the stack.
(“How many elements?”)
3. Stack Operations:
PUSH()
POP()
7
Amity School of Engineering and Technology
8
Amity School of Engineering and Technology
ARRAY REPRESENTATION
9
Amity School of Engineering and Technology
10
Amity School of Engineering and Technology
STACK OPERATIONS
There are two operations of stack:
1) PUSH Operation
2) POP Operation
11
Amity School of Engineering and Technology
PUSH: PUSH operation is used to push (Insert) an element onto the stack
12
Amity School of Engineering and Technology
POP : POP operation is used to pop (delete) an element from the stack
Goto Step 4
[End of if structure]
Step 4: EXIT
13
Amity School of Engineering and Technology
Time Complexity
Push() O(1)
Pop() O(1)
Display() O(n)
16
Amity School of Engineering and Technology
17