Download presentation
Presentation is loading. Please wait.
Published byLenard Sparks Modified over 9 years ago
1
DATA STRUCTURE Presented By: Mahmoud Rafeek Alfarra Using C# MINISTRY OF EDUCATION & HIGHER EDUCATION COLLEGE OF SCIENCE AND TECHNOLOGY KHANYOUNIS- PALESTINE Information Technology, 3’rd Semester Lecture 9 & 10: Stack
2
Outline What is stack ? What is the main Stack’s Operations? Stack implementation Stack’s application Examples (discovering other operations) Emank X Mezank !!
3
What is stack ? A stack is a constrained version of a linked list. A stack takes new nodes and releases nodes only at the top. For this reason, a stack is referred to as a last-in, first-out (LIFO) data structure. 3 Presented & Prepared by: Mahmoud R. Alfarra
4
What is stack ? We define a stack as a list of items that are accessible only from the end of the list, which is called the top of the stack. 4 Presented & Prepared by: Mahmoud R. Alfarra Top
5
What is the main Stack’s Operations? 5 Presented & Prepared by: Mahmoud R. Alfarra The primary operations to manipulate a stack are push and pop. The Push operation adds an item to the top of the stack. The Pop operation removes item from the top of the stack. The Peek operation just views the top item without actually removing it.
6
6 Presented & Prepared by: Mahmoud R. Alfarra What is the main Stack’s Operations?
7
7 Presented & Prepared by: Mahmoud R. Alfarra What is the main Stack’s Operations?
8
Stack implementation 8 Presented & Prepared by: Mahmoud R. Alfarra We’ll implement the stack as a class, called CStack. The items of this stack are objects of class list( car, table, …) This means that, the implementation of stack as the linked list and differ just in the operations.
9
Stack’s application 9 Presented & Prepared by: Mahmoud R. Alfarra Stacks have many interesting applications. For example, when a program calls a method, the called method must know how to return to its caller, so the return address is pushed onto the program execution stack. If a series of method calls occurs, the successive return values are pushed onto the stack in last-in, first-out order so that each method can return to its caller.
10
Stack’s application 10 Presented & Prepared by: Mahmoud R. Alfarra Stacks support recursive method calls in the same manner that they do conventional non-recursive method calls.
11
Emank X Mezank !! أعظم أسبـاب النجاة استعن بالله
12
Next Lecture Examples (Discovering other operations)
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.