Dynamically Linked Stacks
Steve Paks
Dynamically Linked Stacks
• Linked Stack
int MAX_STACKS 10; /* maximum number of stacks */
Class Element{
int key;
/* other fields */
}
Class Stack{
element item;
Stack link;
}

Stack top[MAX_STACKS];
Dynamically Linked
Stacks(Cont’d)
• Add to a Linked Stack
void add(Stack top, Element item){
Stack temp = new Stack();
if(IS_FULL(temp)){
print(“The memory is full”);
exit(1);
}
temp.item = item;
temp.link = top;
∙∙∙∙ (a)
top = temp;
∙∙∙∙ (b)
}

(a)

item
temp
top

(b)

item

top
Dynamically Linked
Stacks(Cont’d)
• delete from a Linked Stack
Element delete(){
Stack temp = top;
Element item;
if(IS_EMPTY(temp)){
print(“The Stack is empty”);
exit(1);
}
item = temp.item;
∙∙∙∙ (a)
top = temp.link;
∙∙∙∙ (b)
return item;
}
top

(a)

a

item a
temp

(b)

top

More Related Content

PPTX
CSharp v1.0.2
PPT
Educational slides by venay magen
PDF
Collections Framework Begineers guide 2
DOCX
(674335607) cs2309 java-lab-manual
PPTX
Rx – reactive extensions
PDF
Concept of Stream API Java 1.8
PPTX
Stack Data structure
PDF
The Ring programming language version 1.5.2 book - Part 21 of 181
CSharp v1.0.2
Educational slides by venay magen
Collections Framework Begineers guide 2
(674335607) cs2309 java-lab-manual
Rx – reactive extensions
Concept of Stream API Java 1.8
Stack Data structure
The Ring programming language version 1.5.2 book - Part 21 of 181

What's hot (7)

PDF
Tech Talk #4 : RxJava and Using RxJava in MVP - Dương Văn Tới
PPTX
Favor composition over inheritance
PDF
Reactive Extensions
PPT
Grand Central Dispatch
PDF
The Ring programming language version 1.5.1 book - Part 20 of 180
PPTX
Share pointtechies linqtosp-andsbs
PPT
Microsoft Ado
Tech Talk #4 : RxJava and Using RxJava in MVP - Dương Văn Tới
Favor composition over inheritance
Reactive Extensions
Grand Central Dispatch
The Ring programming language version 1.5.1 book - Part 20 of 180
Share pointtechies linqtosp-andsbs
Microsoft Ado
Ad

Viewers also liked (18)

PPTX
Min inconmensurable weight
PPTX
Evaluation expression
PPTX
Good numbers
PPTX
Polynomials
PPTX
PPTX
8150.graphs
PPTX
Hemilton cycle circuit
PPTX
Education systems in Europe
PPT
FIGURAS GEOMETRICAS
PPTX
Dynamically linked queues
PDF
HEEC2015
PPTX
PPTX
N queen
PPTX
Singly linked lists
DOCX
Norway
PPTX
Introduction au développement chimique pharmaceutique
PPTX
Sparse matrices
PPTX
Garden for princess
Min inconmensurable weight
Evaluation expression
Good numbers
Polynomials
8150.graphs
Hemilton cycle circuit
Education systems in Europe
FIGURAS GEOMETRICAS
Dynamically linked queues
HEEC2015
N queen
Singly linked lists
Norway
Introduction au développement chimique pharmaceutique
Sparse matrices
Garden for princess
Ad

Similar to Dynamically linked stacks (20)

PPTX
Stack and its applications
PPTX
Data Structure.pptx
PPT
Stacks data structure with algorithm analysis
PPT
MO 2020 DS Stacks 1 AB.ppt
PPT
Stacks
PDF
please tell me what lines do i alter to make this stack a queue. tel.pdf
PPTX
Project of data structure
PDF
Implement the ADT stack by using an array stack to contain its entri.pdf
PPT
Stacks queues
PDF
DOCX
@author Derek Harter @cwid 123 45 678 @class .docx
PPTX
STACKS implimentarions AND stack applications .pptx
PDF
Please review my code (java)Someone helped me with it but i cannot.pdf
DOCX
Need help with writing the test cases for the following code in java-.docx
PDF
Please implement Stack using Array (capacity 100)- Use template to.pdf
PDF
Chapter 5 Stack and Queue.pdf
DOCX
PDF
I have a stack in Java populated with integers. Im trying to compa.pdf
PPT
Stacks
PPT
Stacks.ppt
Stack and its applications
Data Structure.pptx
Stacks data structure with algorithm analysis
MO 2020 DS Stacks 1 AB.ppt
Stacks
please tell me what lines do i alter to make this stack a queue. tel.pdf
Project of data structure
Implement the ADT stack by using an array stack to contain its entri.pdf
Stacks queues
@author Derek Harter @cwid 123 45 678 @class .docx
STACKS implimentarions AND stack applications .pptx
Please review my code (java)Someone helped me with it but i cannot.pdf
Need help with writing the test cases for the following code in java-.docx
Please implement Stack using Array (capacity 100)- Use template to.pdf
Chapter 5 Stack and Queue.pdf
I have a stack in Java populated with integers. Im trying to compa.pdf
Stacks
Stacks.ppt

Dynamically linked stacks

  • 2. Dynamically Linked Stacks • Linked Stack int MAX_STACKS 10; /* maximum number of stacks */ Class Element{ int key; /* other fields */ } Class Stack{ element item; Stack link; } Stack top[MAX_STACKS];
  • 3. Dynamically Linked Stacks(Cont’d) • Add to a Linked Stack void add(Stack top, Element item){ Stack temp = new Stack(); if(IS_FULL(temp)){ print(“The memory is full”); exit(1); } temp.item = item; temp.link = top; ∙∙∙∙ (a) top = temp; ∙∙∙∙ (b) } (a) item temp top (b) item top
  • 4. Dynamically Linked Stacks(Cont’d) • delete from a Linked Stack Element delete(){ Stack temp = top; Element item; if(IS_EMPTY(temp)){ print(“The Stack is empty”); exit(1); } item = temp.item; ∙∙∙∙ (a) top = temp.link; ∙∙∙∙ (b) return item; } top (a) a item a temp (b) top