slide1 n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
STACK PowerPoint Presentation
Download Presentation
STACK

Loading in 2 Seconds...

play fullscreen
1 / 9

STACK - PowerPoint PPT Presentation


  • 230 Views
  • Uploaded on

DATA STRUCTURE. STACK. Stack. A stack is a list of element in which an element may be inserted or deleted only at one end, called the top of the stack. This means in particular ,that elements are removed from a stack in the reverse order of thet in which they were inserted into the stack.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'STACK' - waldo


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
stack
Stack
  • A stack is a list of element in which an element may be inserted or deleted only at one end, called the top of the stack. This means in particular ,that elements are removed from a stack in the reverse order of thet in which they were inserted into the stack.
  • Stack is also called last-in-first –out (LIFO)type of list .
example of stack
Example of stack
  • Stack of book
  • Stack of pennies
two basic operation
Two basic operation
  • PUSH is the term used to insert an element into a stack
  • POP is the term used to delete an element from a stack
diagram of push operation
Diagram of push operation

top

top

F

E

A

B

C

D

top

E

A

B

C

D

A

B

C

D

top

Push( F)

Push (E)

diagram of pop operation
Diagram of POP operation

A

B

C

D

A

B

C

A

B

top

top

top

POP( C)

POP (D)

implementation of stack
Implementation of stack
  • Static implementation of stack
  • Dynamic implementation of stack
static implementation of stack
Static implementation of stack
  • Static implementation of stack uses of array to create stack.
  • Therefore a stack can be declared as a structure containing two fields .

Ex:

#define MAXSIZE 100

Strcut stack{int top;

int element[MAXSIZE]

};

Struct stack s;

dynamic implementation of stack
Dynamic implementation of stack
  • Dynamic implementation is also called linked list representation and uses pointer to implement the stack type of data structure
  • Ex:

Strcut node{int info;

int node *next;

};

Struct node *s;