0% found this document useful (0 votes)
60 views4 pages

An Array Based Implementation of STACK With The Help of Algorithm For Following Functions - Push - Pop

This document provides instructions for a lab session on implementing a stack using an array. The objectives are to understand stacks, an array-based implementation of a stack, and stack operations. Students are instructed to write a program to perform push, pop, display, and top operations on a stack. They are then asked to test the program by pushing and popping various elements onto a stack of size 6. The document also provides background information on stacks, including their LIFO nature and common stack operations like push, pop, empty, full, etc.

Uploaded by

kevipa6802
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)
60 views4 pages

An Array Based Implementation of STACK With The Help of Algorithm For Following Functions - Push - Pop

This document provides instructions for a lab session on implementing a stack using an array. The objectives are to understand stacks, an array-based implementation of a stack, and stack operations. Students are instructed to write a program to perform push, pop, display, and top operations on a stack. They are then asked to test the program by pushing and popping various elements onto a stack of size 6. The document also provides background information on stacks, including their LIFO nature and common stack operations like push, pop, empty, full, etc.

Uploaded by

kevipa6802
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
You are on page 1/ 4

Departemnent of Computer Sciences 1/4 Semester Spring 2016

CSL-221: Data Structures & Algorithms Lab 05: STACK

LAB An array based implementation of STACK with the


help of algorithm for following functions
06 •

Push()
Pop()

Objective(s): Upon completion of this lab session, Student will be able to


understand the following concepts
1 STACK
2 An array based implementation of STACK
3 Operation of STACK

LabTask(s):

Write a program as follows for STACK


1

----------------------Array based implementation of STACK-----------------------------------

1. Push an element on stack


2. Pop an element from stack
3. Display all
4. Top element
5. Exit
-------------------------------------------------------------------------------------------------------------

Please Enter Your Choice:

Test the program using the following procedure: STACK of size N=6
2
1. Call PUSH(5)
2. Call PUSH(2)
3. Call PUSH(3)
Departemnent of Computer Sciences 2/4 Semester Spring 2016
CSL-221: Data Structures & Algorithms Lab 05: STACK

4. Call POP()
5. Call PUSH(6)
6. Call PUSH(9)
7. Call PUSH(3)
8. Call DISPLAY()
9. Call TOP()

LAB ACTIVITIES RELATED THEORY


Stack

Stack: is an ordered group of homogeneous items of elements.


Departemnent of Computer Sciences 3/4 Semester Spring 2016
CSL-221: Data Structures & Algorithms Lab 05: STACK

Elements are added to and removed from the top of the stack (the most recently added items
are at the top of the stack).
The last element to be added is the first to be removed (LIFO: Last In, First Out).

Stack Operation

MakeEmpty
Boolean IsEmpty
Boolean IsFull
Push (ItemTypenewItem)
Pop (ItemType& item) (or pop and top)

Push(ItemTypenewItemId)

Function: Adds newItem to the top of the stack.


Preconditions: Stack has been initialized and is not full.
Postconditions: newItem is at the top of the stack.

Pop(ItemType&Item)

Function: Removes topItem from stack and returns it in item.


Preconditions: Stack has been initialized and is not empty.
Postconditions: Top element has been removed from stack and item is a copy of the removed
element.
Departemnent of Computer Sciences 4/4 Semester Spring 2016
CSL-221: Data Structures & Algorithms Lab 05: STACK

-------------------------------------------------------------END------------------------------------------------------------

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy