0% found this document useful (0 votes)
3 views5 pages

Stack Operations Implementation Guide

The document outlines an algorithm for implementing stack operations using an array of size 5. It includes operations for pushing, popping, and displaying stack elements, along with error handling for stack overflow and underflow. The algorithm is structured in a step-by-step format to guide the implementation process.

Uploaded by

malathik932004
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views5 pages

Stack Operations Implementation Guide

The document outlines an algorithm for implementing stack operations using an array of size 5. It includes operations for pushing, popping, and displaying stack elements, along with error handling for stack overflow and underflow. The algorithm is structured in a step-by-step format to guide the implementation process.

Uploaded by

malathik932004
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Ex. No.

1a Stack Array Date:

Aim

To implement stack operations using array.

Algorithm

1. Start

2. Define a array stack of size max = 5

3. Initialize top = -1

4. Display a menu listing stack operations

5. Accept choice

6. If choice = 1 then

If top < max -1

Increment top

Store element at current position of top

Else

Print Stack overflow

Else If choice = 2 then

If top < 0 then

Print Stack underflow

Else

Display current top element Decrement top

Else If choice = 3 then


Display stack elements starting from top

7. Stop

Ex. No. 1a Stack Array


Date:

Aim
To implement stack operations using array.

Algorithm

1. Start
2. Define a array stack of size max = 5
3. Initialize top = -1
4. Display a menu listing stack operations
5. Accept choice
6. If choice = 1 then
If top < max -1
Increment top
Store element at current position of top
Else
Print Stack overflow
Else If choice = 2 then
If top < 0 then
Print Stack underflow
Else
Display current top element
Decrement top
Else If choice = 3 then
Display stack elements starting from top
7. Stop
Ex. No. 1a Stack Array
Date:

Aim
To implement stack operations using array.

Algorithm

1. Start
2. Define a array stack of size max = 5
3. Initialize top = -1
4. Display a menu listing stack operations
5. Accept choice
6. If choice = 1 then
If top < max -1
Increment top
Store element at current position of top
Else
Print Stack overflow
Else If choice = 2 then
If top < 0 then
Print Stack underflow
Else
Display current top element
Decrement top
Else If choice = 3 then
Display stack elements starting from top
7. Stop
Ex. No. 1a Stack Array
Date:

Aim
To implement stack operations using array.

Algorithm

1. Start
2. Define a array stack of size max = 5
3. Initialize top = -1
4. Display a menu listing stack operations
5. Accept choice
6. If choice = 1 then
If top < max -1
Increment top
Store element at current position of top
Else
Print Stack overflow
Else If choice = 2 then
If top < 0 then
Print Stack underflow
Else
Display current top element
Decrement top
Else If choice = 3 then
Display stack elements starting from top
7. Stop
Ex. No. 1a Stack Array
Date:

Aim
To implement stack operations using array.

Algorithm

1. Start
2. Define a array stack of size max = 5
3. Initialize top = -1
4. Display a menu listing stack operations
5. Accept choice
6. If choice = 1 then
If top < max -1
Increment top
Store element at current position of top
Else
Print Stack overflow
Else If choice = 2 then
If top < 0 then
Print Stack underflow
Else
Display current top element
Decrement top
Else If choice = 3 then
Display stack elements starting from top
7. Stop
Ex. No. 1a Stack Array
Date:

Aim
To implement stack operations using array.

Algorithm

1. Start
2. Define a array stack of size max = 5
3. Initialize top = -1
4. Display a menu listing stack operations
5. Accept choice
6. If choice = 1 then
If top < max -1
Increment top
Store element at current position of top
Else
Print Stack overflow
Else If choice = 2 then
If top < 0 then
Print Stack underflow
Else
Display current top element
Decrement top
Else If choice = 3 then
Display stack elements starting from top
7. Stop

You might also like