SVKMs NMIMS
Mukesh Patel School of Technology Management & Engineering
Computer Engineering Department
Program: B.Tech. Sem V
Course: Design and Analysis of Algorithm
List of Experiments
w.e.f. 21st Jul 2015
Faculty: Abhay Kolhe
Exp No.
1
2.
3.
Title
Implementation of Stack & Queue
using array.
Implementation of Linked List.
Develop a Menu Drive Program with
Following menu options:
1. Insert
2. Delete
3. Search
4. Print
5. Exit
Implementation of Binary Search
Tree. Develop a Menu Driven
Program with following options:
1. Creation
2. Insert
3. Delete
4. Search
5. Display
6. Exit
Implementation of Graph Traversal
Techniques DFS & BFS.
Implementation of Heap Sort.
Implementation of Linear Search and
Binary Search.
Implementation of a divide & conquer
algorithm - Quick Sort
Implementation of a Greedy
Technique Algorithm Prims &
Kruskal Algorithm.
Prerequisite*
Knowledge of Arrays and C
Programming.
Knowledge of self-referential
structure, pointers, pointer to
pointer and C Programming.
Knowledge of Binary Search
tree concept and insert, delete,
search operations on it.
Knowledge of Graph concepts,
storage of a graph in computer
and traversal techniques of a
graph DFS & BFS.
Knowledge of Heapify
method(Max-Heap or MinHeap).
Knowledge of Arrays and
handling of arrays, Linear
search and binary search.
Knowledge of divide & conquer
strategy of algorithm design,
Arrays and handling of arrays.
Knowledge of Greedy
Technique of Algorithm design
Technique, graph, its handling
and minimum
CO#
CO1
CO1
CO2
CO2
CO3
CO3
CO4
CO4
Implementation of Dynamic
Programming Technique Longest
Common Subsequence
10
Implementation of Backtracking
Technique of Algorithm Technique
Sum of subsets problem.
spanning tree
Knowledge of Dynamic
Programming Technique of
Algorithm Design, longest
common subsequence problem.
Knowledge of backtracking
technique of algorithm design
technique, sum of subsets
problem.
* Students are expected to be ready with the prerequisite before attending the lab
CO4
CO5
LAB Manual
PART A
(PART A : TO BE REFFERED BY STUDENTS)
Experiment No.01
A.1 Aim:
Write a program to implement stack and queue using arrays.
A.2 Prerequisite:
1 Concepts C Programming
2. Knowledge of fundamentals of arrays.
2. Knowledge of handling of arrays.
A.3 Outcome:
After successful completion of this experiment students will be able to
1. Differentiate between stack & queue.
2.Identify application of stack.
3.Identify applications of queue.
A.4 Theory:
A.4.1. Introduction of Stack
Conceptually, a stack is simple: a data structure that allows adding and removing
elements in a particular order. Every time an element is added, it goes on the top of the
stack; the only element that can be removed is the element that was at the top of the
stack. Consequently, a stack is said to have "first in last out" behavior (or "last in, first
out"). The first item added to a stack will be the last item removed from a stack.
Stacks have some useful terminology associated with them:
Push To add an element to the stack
Pop To remove an element from the stock
Peek To look at elements in the stack without removing them
LIFO Refers to the last in, first out behavior of the stack
Pushing/Popping a Stack
Figure 1: Stack Operations
A.4.2. Introduction of Queue
The queue is a data structure that allows use of two ends of it. I mean from one
end of the queue you can insert the elements and from another end of the queue
you can delete the elements. The Queue can be formally defined as ordered
collection of elements that has two ends named as front and rear. From the front
end one can delete the elements and from the rear end one can insert the
elements. The queue is also called as First in First out (FIFO) data structure.
Figure 2: Queue Operations
A.5 Procedure/Algorithm:
A.5.1:
TASK 1: Stack Implementation
Push ( )
1. start
2. read n
3. if top greater than (n-1) then
4. print overflow
5. else
6. top = top+1
7. data[top]=d
8. print element pushed to stack
9. stop.
2. Pop( )
1. start
2. if top< 0 then
3. print underflow
4. else
5.d = data[top]
6. top = top-1
7. print element is popped from the stack
8. stop.
Save the file and name it as EX1_Task1_your Roll no.c
TASK 2: Queue Implementation
For Insert Operation
1. If Rear = N then Print: Overflow and Return.
/*Queue already filled..*/
2. Set Rear := Rear +1
3. Set Queue[Rear] := Item
Here N is the maximum size of the Queue.
For Delete Operation
1. If Front = N+1 then Print: Underflow and Return.
/*Queue Empty
2. Set Item := Queue[Front]
3. Set Front := Front + 1
Save the file and name it as EX1_Task2_your Roll no.c
**********************
PART B
(PART B : TO BE COMPLETED BY STUDENTS)
(Students must submit the soft copy as per following segments within two hours of the
practical. The soft copy must be uploaded on the Blackboard or emailed to the
concerned lab in charge faculties at the end of the practical in case the there is no Black
board access available)
Roll No.
Class :
Date of Experiment:
Grade :
Date of Grading:
Name:
Batch :
Date of Submission
Time of Submission:
B.1 Software Code written by student:
(Paste your c/c++ code completed during the 2 hours of practical in the lab here)
B.2 Input and Output:
(Paste your program input and output in following format, If there is error then paste the specific
error in the output part. In case of error with due permission of the faculty extension can be given to
submit the error free code with output in due course of time. Students will be graded accordingly.)
Input Data:
Output Data:
B.3 Observations and learning:
(Students are expected to comment on the output obtained with clear observations and learning for
each task/ sub part assigned)
B.4 Conclusion:
(Students must write the conclusion as per the attainment of individual outcome listed above and
learning/observation noted in section B.3)
B.5 Question of Curiosity
(To be answered by student based on the practical performed and learning/observations)
Q.1 What are the disadvantages of implementation of Stack & Queue using arrays?
Q.2 What are the ways to overcome the disadvantages listed in the answer of Q.1?
Q.3 Compare & contrast Stack & Queue.
Q.4 List the application of stack and queue in day to day life as well as in computer
engineering field.
************************