Introducing 

Prezi AI.

Your new presentation assistant.

Refine, enhance, and tailor your content, source relevant images, and edit visuals quicker than ever before.

Loading…
Transcript

STACK DATA STRUCTURE

Let's Go!

By Anupam Tudu

STACK

A stack is an abstract data type (ADT) that holds an ordered, linear sequence of items. A stack has a last in, first out (LIFO) or first in, last out (FILO) structure.

Primitive Operations on stack ->

isFull() function

This function is used to check whether the stack is full or not.

isFull()

isEmpty() function

This function is used to check whether the stack is empty or not.

isEmpty()

push() function

This function is used to push elements into the stack.

Steps in push() operation

push()

  • Check if the stack is full
  • If the stack is full, produce an error and exit
  • If the stack is not full, increment top to point next empty space
  • Add data element to the stack location, where top is pointing

pop() function

This function is used to delete one element from the top of the stack.

Steps in pop() operation

pop()

  • Check if the stack is empty
  • If the stack is empty, produce an error and exit
  • If the stack is not empty, access the data element at which top is pointing
  • Decrease the value of top by 1

peek() function

This function is used to get the top most element of the stack.

peek()

Learn more about creating dynamic, engaging presentations with Prezi