This presentation depicts the definition of stack, queue and subroutine. It s a minute presentation best for engineering students as well as reference for last minute notes or term paper presentation. Share and Help others .
2. CONTENT
1. STACK OVERVIEW
2. QUEUE OVERVIEW
3. APPLICATION OF STACK AND QUEUE
4. SUBROUTINE OVERVIEW
5. SUBROUTINE APPLICATION WITH EXAMPLE
3. STACK
• Stack is a linear data structure which follows a particular
order in which the operations are performed. The order may
be LIFO(Last In First Out) or FILO(First In Last Out).
• Insertion and deletion takes place at one end.
Example :
Plates stacked over one another in canteen
Top
Push Pop
4. QUEUE
• A Queue is a linear structure which follows a particular
order in which the operations are performed. The order
is First In First Out (FIFO).
• Insertion takes place at the rear end, and deletion takes
place at the front end.
Example :
Customers standing in a line at canteen
Front
Rear
Enqueue
Dequeue
5. QUEUE
• Queue is used in solving problems having sequential processing.
• Applied as waiting lists for a single shared resource like CPU, Disk,
Printer.
• Applied as buffers on MP3 players and portable CD players.
• Applied on Operating system to handle interruption.
• Applied to add song at the end or to play from the front.
STACK
• Stack is used in solving problems works on recursion.
• Evaluation of Arithmetic Expressions
• Backtracking
• Delimiter Checking
• Reverse a Data
• Processing Function Calls
APPLICATION OF STACK
AND QUEUE
Stack as well as Queue are used in manipulating the flow of data in a network.
6. SUB ROUTINE
The block of instruction which carries out a specific and well defined task
is called a subroutine. Moreover, it is a small block of instruction, written
and stored separately.
Working principle of Sub-Routine
1. Halts the main program.
2. Provide returning to the main point.
3. Transfer control is called subroutine.
4. Executes the subroutine.
5. Revert to the main routine.
Program
Start
Subroutine
Call
Rest of
Program
Program
End
Subroutine
Start
Subroutine
Program
Subroutine
End
Main Program
Subroutine
Transfer
Return
7. SUB ROUTINE
• Decomposing a complex programming task into simpler steps.
• Reducing duplicate code within a program
• Enabling reuse of code across multiple programs
• Dividing a large programming task among various
programmers or various stages of a project
• Hiding implementation details from
• Improving readability of code
• Improving traceability
APPLICATIONS
EXAMPLE
SUBROUTINE
SUB multiply(INT : number)
for i runs 1 to 5
(e.g. for(i=1;i<=5;i++))
OUTPUT number * i
NEXT
END SUB
PROGRAM
INPUT num
CALL multiply(num)
8. CONCLUSION
• Stacks : A stack is a basic data structure that can be logically thought as
linear structure represented by a real physical stack or pile, a structure
where insertion and deletion of items takes place at one end called top of
the stack.
• Queue : Queue is an abstract data structure, somewhat similar to Stacks.
Unlike stacks, a queue is open at both its ends. One end is always used to
insert data (enqueue) and the other is used to remove data (dequeue).
• Subroutine : Subroutine is a sequence of program instructions that performs
a specific task, packaged as a unit. This unit can then be used in programs
wherever that particular task should be performed.