انت هنا الان : شبكة جامعة بابل > موقع الكلية > نظام التعليم الالكتروني > مشاهدة المحاضرة

Stack data structure

الكلية كلية تكنولوجيا المعلومات     القسم قسم البرامجيات     المرحلة 2
أستاذ المادة حوراء شريف حمزة حسين       14/10/2012 07:59:32
Stack is an ordered list in which all insertions and deletions are made at one end, called the top.
Stack is a data structure that is particularly useful in applications involving reversing.
LIFO : Last In First Out
Stack Implementation
Stack can be implemented in two different ways:
1. Contiguous stack: the stack is implemented as an array.
2. Linked stack: pointers and dynamic memory allocation is used to implement the stack.
Stack operations
push(e): Insert element e, to be the top of the stack.
pop(): Remove from the stack and return the top element on the stack; an error occurs if the
stack is empty.
size(): Return the number of elements in the stack.
isEmpty(): Return a Boolean indicating if the stack is empty.
top(): Return the top element in the stack, without removing it; an error occurs if the stack is
empty.
Initialise: creates/initialises the stack
Initialise
Creates the structure – i.e. ensures that the structure exists but contains no elements e.g.
Initialise(S) creates a new empty stack named S
push
e.g. Push(X,S) adds the value X to the TOP of stack S


6
pop
e.g. Pop(S) removes the TOP node and returns its value



Example



We could try the same example with actual values for A, B and C.

المادة المعروضة اعلاه هي مدخل الى المحاضرة المرفوعة بواسطة استاذ(ة) المادة . وقد تبدو لك غير متكاملة . حيث يضع استاذ المادة في بعض الاحيان فقط الجزء الاول من المحاضرة من اجل الاطلاع على ما ستقوم بتحميله لاحقا . في نظام التعليم الالكتروني نوفر هذه الخدمة لكي نبقيك على اطلاع حول محتوى الملف الذي ستقوم بتحميله .