DSA Self Placed: Geeksforgeeks
DSA Self Placed: Geeksforgeeks
DSA Self Placed: Geeksforgeeks
~GEEKSFORGEEKS
BY-
MOHAMMAD AMIR IDREESI
Reg No:11811970
OBJECTIVES
Types:
Conversion of expressions.
Infix to postfix, postfix to prefix, prefix to infix, vice- versa.
Evaluation of expressions.
Arithmetic expression in the form of either postfix or
prefix.
can be easily evaluated.
Recursion.
Ex. Tower of Hanoi etc.
Other applications.
Ex: Checking if a string is a palindrome or not.
System Software and Compiler Design
Towers of Hanoi
Three pegs labeled A, B,C
In A, there are finite number of disks with decreasing size
Objective- move the disks from A to C using B as an
auxiliary.
The rules of the game are as follows
Only one disk may be moved at a time.
At no time can a larger disk be placed on a smaller disk
A B C
Procedure
For n disks
Move the top n-1 disks from peg A to peg B
Move the top disk from peg A to C
Move the top n-1 disks from peg B to peg C
Tower(N-1, BEG, END, AUX)
Tower(1,BEG, AUX, END)
Tower(N-1,AUX,BEG,END)
o Algorithm
o Tower(N,BEG,AUX,END)
o If N=1, then BEG END
o return
o Tower(N-1, BEG,END,AUX) // Move N-1 disks from BEG to AUX
o BEG-----END
o Tower(N-1, AUX, BEG,END)
o return
Queues
A queue is defined as a
special type of data
structure where the The end from where the
elements are inserted elements are inserted is REAR end.
from one end and called
elements are deleted from
the other end.
Structure.
Operations Performed on Queues