DS Question Papers (2009 To 2023)
DS Question Papers (2009 To 2023)
DS Question Papers (2009 To 2023)
______
Q.1 (a) Define data structure. List the various linear and non-linear data 05
structures and explain them in brief.
(b) Discuss the basic operations performed with linear structure. 05
(c) What is recursion? Write a C program for GCD using recursion. 04
Q.2 (a) Write an algorithm to convert infix expression to postfix expression. 05
(b) Write an algorithm for evaluation of postfix expression and evaluation 07
the following expression showing every status of stack in tabular form.
(i) (A+B*C/D-E+F/G/(H+I))
(ii) ( A + B ) * C + D / ( B + A * C ) + D
(c) Explain Difference between Stack and Queue. 02
Q.4 (a) Explain Sequential Files and Indexed Sequential Files Structures. 08
(b) Explain the Preorder, Inorder and Postorder traversal techniques of the 06
binary tree with suitable example.
OR
Q.4 (a) Explain the terms: File, Field, Record, Database, Key. 06
1
(b) Which are the basic traversing techniques of the Graph? Write the 08
algorithm of any one of them.
Q.5 (a) Construct the AVL search tree by inserting the following elements in 06
the order of their occurrence.
64, 1, 44, 26, 13, 110, 98, 85
(b) Discuss following with reference to graphs. 08
(i) Directed graph (ii) Undirected graph (iii) Degree of vertex
(iv)Null graph
OR
Q.5 (a) Explain matrix and linked list representation of a graph 06
(b) Discuss following with reference to trees. 08
(i) Height of the tree (ii) Binary tree (iii)Strictly binary tree
(iv) Sibling
***********
2
Seat No.: _____ Enrolment No.______
Q1 A Write an algorithm for push, pop and empty operations on stack. Using above 07
functions write an algorithm to determine if an input character string is of the
form
aibi where i>=1 i.e. no of a should be equal to no of b
A +B-C*D/E +F$G/(I+J)
C What are the advantages and disadvantages of stack and queue implemented 04
using linked list over array?
Q2 A Write an algorithm to perform each of the following operations on Circular 07
singly linked list using header node
1. add node at the end
2. add node at beginning
3. delete a node which contain element x
4. insert a node containing x after node having address p
1
B Construct a tree for the given inorder and postorder traversals 05
Inorder DGBAHEICF
Postorder GDBHIEFCA
C Why is Threaded binary tree required? Draw a right in threaded binary tree 05
for the given tree in Fig. 1
OR
Q3 A Construct binary search tree for the following data 07
10,3,15,22,6,45,65,23,78,34,5
Find its inorder, preorder and postorder travesal
B Define height of the binary tree. Define height balanced tree with its 07
advantages. Construct a height balanced binary tree (AVL tree) for the
following data
42,06,54,62,88,50,22,32,12,33
Q4 A Consider the graph shown in Fig 2. Find depth-first and breadth first 07
traversals of this graph starting at A
B Define spanning tree and minimum spanning tree. Find the minimum 07
spanning tree of the graph shown in Fig 3.
OR
Q4 A Give example and applications of directed and undirected graphs. Find the 07
adjacency matrix for the graph shown in Fig 4.
B Apply Dijkstra’s algorithm to find shortest path between vertex A and vertex 07
F5 for the graph shown in Fig 5.
Q5 A What are the advantages of Multiway search tree in disc access? 07
Construct B tree of order 5 for the following data
1,7,6,2,11,5,10,13,12,20,16,24,3,4,18,19,14,25
B What are the advantages of Hashing? Discuss problem of collision in 07
Hashing. Also discuss collision resolution techniques.
OR
Q5 A The integers given below are to be inserted in a hash table with 5 locations 07
using chaining to resolve collisions. Construct hash table and use simplest
hash function.
1,2,3,4,5,10,21,22,33,34,15,32,31,48,49,50
B Define following terms 07
(1) Time and space complexity of an algorithm
(2) Sparse matrix
(3) Sequential , direct and Index sequential access of files
*****
2
A A
B E C
H B
C D F D E
F
G Fig 2
Fig 1
A 2
B D 6
5 1
4 4 7 F
A
1
3 E 2
6 3
B C E
6
5 7 5
2
D Fig 5
1
C
Fig 3
6
3
2
5
4
Fig 4
3
GUJARAT TECHNOLOGICAL UNIVERSITY
B.E. Sem-III Regular / Remedial Examination December 2010
Q.1 14
(a) What is sparse matrix? Explain
(b) What does abstract data type means?
(c) What is the difference between linear and nonlinear data structure.
(d) Consider the following queue, where queue is a circular queue having 6
memory cells. Front=2, Rear=4
Queue: _, A, C, D, _, _
Describe queue as following operation take place:
F is added to the queue
Two letters are deleted
R is added to the queue
S is added to the queue
One letter is deleted
(e) Give definition of a) Complete binary tree b) Height of tree
(f) Give difference between recursion and iteration
(g) What is 2-3 tree?
Q.2 (a) Translate the following string into Polish notation and trace the content of 07
stack (a + b ^ c ^ d) * ( e + f / d )
(b) Write an algorithm which will check that the given string belongs to following 05
grammar or not
L={wcwR | w Є {a,b}*}(Where wR is the reverse of w)
(c) Convert the following string into prefix : 02
A-B/(C*D^E)
OR
(b) Write a function to implement insertion of an element in circular queue using 05
link list.
(c) Write an algorithm to change the i th value of stack to value X 02
OR
Q.3 (a) What is the meaning of height balanced tree? How rebalancing is done in 04
height balanced tree.
(b) Write a short note on doubly link list 04
(c) Write an advantage of link list , doubly link list and circular link list 04
(d) Explain priority queue 02
1
Q.4 (a) Create a binary search tree for the following data : 06
50 ,25 ,75, 22,40,60,80,90,15,30
(b) What is graph? How it can be represented using adjacency matrix, what is path 06
matrix? How path matrix can be found out using adjacency matrix .
(c) What is spanning tree ? 02
OR
Q.4 (a) Give traversal order of following tree into inorder, preorder and postorder. 06
Q.5 (a) Explain various multiple key access file organization in brief with advantages 07
and disadvantages of each method.
(b) Explain hashing for direct files. 07
OR
Q.5 (a) What do you mean by hashing? What are various hash function. Explain each 07
one in brief.
(b) List various fundamental file organization techniques and explain each in 07
brief.
*************
2
Seat No.: _____ Enrolment No.______
Q.1 (a) Define Algorithm. Write an algorithm to multiply two matrices. Also 07
Perform Time Analysis for the same.
(b) 1.Differentiate the following terms: [04] 07
a. Liner and Non-Linear Data Structures
b. Primitive and Non-Primitive Data Structures
2. Explain Recursion with the help of an Example. [03]
Q.2 (a) 1. Write down algorithms for performing push and pop 07
operations on a stack. [04]
2. Write an algorithm to convert parenthesized infix expression to
postfix. [03]
(b) Write a Program to perform insert and delete operations on a circular 07
Queue.
OR
(b) 1. Compare the efficiencies of BFS and DFS. [03] 07
2. Give the DFS and BFS spanning tree for the graph given below.
[04]
1
Q.4 (a) 1. Define the following: [03] 07
1. Complete Binary Tree
2. Almost Complete Binary Tree
2. Answer the following for the below given Graph. [04]
Q.5 (a) What is hashing? Explain hash clash and its resolving techniques. 07
(b) Define File and Record. Explain Indexed-Sequential File. Also 07
discuss the advantages and disadvantages of the same.
OR
Q.5 (a) Define Hash Clash. Explain Primary Clustering, secondary clustering, 07
rehashing and double hashing.
(b) State different File Organizations and discuss the advantages and 07
disadvantages of each of them.
*************
2
Seat No.: _________ Enrolment No._______________
Q.2 (a) Write an algorithm to implement PUSH, POP and CHANGE Operations on 07
Stack.
(b) Write short notes on following 07
(i). Storage representation of 2 Dimensional array
(ii).Advantages and disadvantages of linked list over array.
OR
(b) Write short note on following. 07
(i) Evaluation of Postfix Expression using Stack.
(ii) Applications of Trees.
Q.3 (a) Write an algorithm to insert and delete a node in Doubly Linked List. 08
(b) Write an algorithm/program to implement Delete operation into a Circular 06
Queue using array representation of Queue.
OR
Q.3 (a) Write an algorithm/program to implement following operations in the 08
“Singly Linked List”.
(i) Insert the node at end
(ii) Delete the node whose value = Y.
1
Q.4 (a) Create a Binary Search Tree for the following data and do in-order, 06
Preorder and Post-order traversal of the tree.
50, 60, 25, 40, 30, 70, 35, 10, 55, 65, 5
(b) Answer the following. 08
(i) What is recursion ? What care should be taken in writing
recursive function ? Give example of any one recursive
function.
(ii) Compare BFS and DFS traversal methods for Graph.
OR
Q.4 (a) What is Binary Search Tree? Write recursive algorithm/program to 06
implement in-order and pre-order traversal of the Binary Search Tree.
(b) How graph can be represented? Write an algorithm for Breadth First Search 08
Traversal of a Graph.
*************
2
Seat No.: _____ Enrolment No.______
Q.1 (a) What is data structure? Explain linear and non-linear data structure with 03
example.
(b) Define Time complexity and Space complexity. Calculate time complexity 04
for given expression.
for (k=0; k<n; k++)
{
rows[k] = 0;
for(j=0; j<n; j++)
{
rows[k] = rows[k] + matrix[k][j];
total = total + matrix[k][j];
}
}
(c) Write a non-recursive algorithm for Preorder traversal of a binary tree. 07
1
(2) Write a short note on Index sequential file organization.
OR
Q.3 (a) What is sparse matrix? Explain memory representation of sparse matrix. 04
(b) Differentiate between stack & queue. Also explain priority queue. 05
(c) Write a short note on Threaded binary tree. 05
Q.4 (a) Write an algorithm for circular queue that insert an element at rear end. 04
(b) Write a short on Breadth First Search and Depth First Search in graph. 05
(c) Explain the basic two techniques for Collision-resolution in Hashing with 05
example. Also explain primary clustering.
OR
Q.4 (a) Write an algorithm for Double Ended Queue that insert an element at front 04
end.
(b) Write a short note on Spanning tree. 05
(c) Insert 1, 29, 32 and 13 in the following Height balanced tree. For each 05
insertion, draw the balanced tree using AVL rotation.
Q.5 (a) Write an algorithm for inserting and deleting an element into circular linked 07
list.
(b) Explain terms: (1) Path (2) Graph 04
(c) Evaluate following prefix expression. 03
+*AB-C+C*BA (A= 4, B=8,C=12)
OR
Q.5 (a) Write an algorithm to insert a new node into orderly doubly linked list. 07
(b) Explain terms: (1) Cycle (2) Complete binary tree 04
(c) Write difference between singly linked list and doubly linked list. 03
*************
2
Seat No.: ________ Enrolment No.___________
Q.1 (a) Explain PUSH and POP operation of the stack with algorithm. 07
(b) Write an algorithm for insert operation at end of Linked List. 07
Q.2 (a) What is use of binary search tree? Construct sequential order binary tree 07
(binary search tree) for following values.
10,15,17,8,7,9,11,12,13,4,14,5
(b) Explain delete operation of doubley linked list. 07
OR
(b) What are the advantages of doubley linked list? Write a C function to find 07
maximum element from doubley linked list.
OR
Q.3 (a) Explain insert and delete function of circular queue. 07
(b) Find value of following postfix expression using stack trace. 07
(i) 546+*493 / + *
(ii) 3 5 * 6 2 / +.
Q.4 (a) Trace procedure to convert following forest into binary tree. 06
A
H
B C
I J K
D G
E
L
.
(b) Define : (i) Tree and binary tree (ii) intermediate node and leaf node 08
(iii) Sibling node and adjacent node (iv) path matrix.
OR
Q.4 (a) Find a post order and preorder traversal of a following tree. 07
B C
D E
G
OR
Q.5 (a) Write a short note on spanning tree. 07
(b) Write a short note on inverted key file organization. 07
*************
Seat No.: ________ Enrolment No.___________
Q.1 (a) Define sparse matrix. Briefly explain representation of sparse matrix with the 07
help of link list and array.
(b) Define data structure. Briefly explain linear and non linear data structures 07
with their applications
Q.2 (a) Convert following infix expressions to the postfix expressions. Shows stack 07
trace.
A/B$C+D*E/F-G+H
(A+B)*D+E/(F+G*D)+C
(b) Write an algorithm for stack operations Push, Pop and Empty. Assume stack 07
is implemented using array
OR
(b) What is the advantage of postfix expression over infix expression? Write an 07
algorithm of postfix expression evaluation.
Q.3 (a) Write a C function search (l, x) that accepts a pointer l to a list of integers 07
and returns a pointer to a node containing x if it exists and the null pointer
otherwise.
(b) Write insert and remove functions for queue if it is implemented using 07
circular link list.
OR
Q.3 (a) Briefly explain advantages of doubly link list over singly link list. Write 07
function delete (p, &x) which delete the node pointed by p in doubly link list.
(b) Briefly explain advantages of binary search tree. Construct binary search tree 07
for the following elements
8,3,11,5,9,12,13,4,6,20
Q.4 (a) The inorder and preorder traversal of a binary tree are 07
dbeafcg
a b d e c f g respectively
Construct binary tree and find its postorder traversal.
(b) Define Directed graph, spanning tree and minimum spanning tree. Find 07
minimum spanning tree for the graph shown in Figure 1.
OR
Q.4 (a) Answer the following
1. The height of a binary tree is the maximum number of edges in any 01
root to leaf path. Define the maximum number of nodes in a binary
tree of height h.
(b) The Breadth First Search algorithm has been implemented using the queue 07
data structure. Find breadth first search for the graph shown in Figure 2 with
starting node M
Q.5 (a) The keys 12, 18, 13, 2, 3, 23, 5 and 15 are inserted into an initially empty 07
hash table of length 10 using open addressing with hash function h(k) = k
mod 10 and linear probing. What is the resultant hash table?
(b) Define AVL tree. Construct AVL tree for following data 07
10,20,30,40,50,60,70,80
OR
Q.5 (a) What are the advantages of Multi way search tree over binary search tree? 07
Construct 2-3 tree for the following data
12, 50, 85, 6, 10, 37, 100, 120, 25, 70
*************
Figure 1
Figure 2
2/2
Seat No.: ________ Enrolment No.___________
Q.2 (a) What is Stack? Write down algorithms for performing POP and PEEP 07
operations on a stack.
(b) Answer the following. 07
(i) Compare Simple Queue and Circular Queue.
(ii) Define the following terms:
Path, Cycle, Degree of vertex, Sibling.
OR
(b) Write an algorithm to implement insert and delete operation into a Circular 07
Queue using array representation of Queue.
*************
1
2
Seat No.: ________ Enrolment No.___________
1
(b) Write short notes on (i) Height Balanced Tree. (ii) Indexed-Sequential Files 07
Q.5 (a) What do you mean by Hashing? Explain any FOUR hashing techniques 07
(b) Define the following terms 07
i) Node
ii) Sibling
iii) Path
iv) Indegree & outdegree of a vertex
v) Connected graph
OR
Q.5 (a) Compare and contrast Prim’s and Kruskal’s algorithm with the help of an 07
example
(b) Explain AVL tree with the help of an example also show insertion and deletion 07
with the help of an example.
Fig: 1. Fig :2
*************
2
Seat No.: ________ Enrolment No.___________
Q.1 (a) What is data structure? Explain linear and non-linear data structure with 03
example.
(b) Discuss best case, average case and worst case time analysis with example. 04
(c) Explain PUSH and POP operation of the stack with algorithm. 07
Q.2 (a) Write an algorithm to perform insert and delete operation on single queue. 07
(b) (a) Convert the following infix expression to postfix prefix form. 07
(( A –( B +C))* D) $ ( E +F )
(b) Evaluate the following infix expression.
2 $3+5*2$2–6/6
OR
(b) Define the following term : Path, Cycle, Degree of vertex, Sibling, Height 07
Balanced Tree, Strictly binary tree, in degree
Q.3 (a) Explain delete operation in doubly link list. 07
(b) What is the difference between queue & Dqueue . Explain insertion operation in 07
Dqueue.
OR
Q.3 (a) Write an algorithm to reverse a given single link list. 07
(b) Create a binary search tree by inserting following nodes in sequence. 07
68,85,23,38,44,80,30,108,26,5,92,60
Write inorder,preorder and post order traversal of the above generated Binary
search tree.
Q.4 (a) Write an algorithm to perform traversal of Binary search tree 07
(b) Explain AVL tree with the help of an example also show insertion and deletion 07
with the help of an example.
OR
(a) Write a short note on :spanning tree , threaded binary tree 07
(b) Explain the basic two techniques for Collision-resolution in Hashing with 07
example. Also explain primary clustering.
Q.5 (a) Compare and contrast Prim’s and Kruskal’s algorithm with the help of an 07
example
(b) Explain various multiple key access file organization in brief with 07
advantages and disadvantages of each method.
OR
Q.5 (a) What do you mean by Hashing? Explain any FOUR hashing techniques 07
(b) Explain and differentiate BFS and DFS graph traversal method with suitable 07
graph.
*************
1
Seat No.: ________ Enrolment No.___________
GUJARAT TECHNOLOGICAL UNIVERSITY
BE - SEMESTER–III • EXAMINATION – WINTER • 2014
Subject Code: 2130702 Date: 01-01-2015
Subject Name: Data Structure
Time: 02.30 pm - 05.00 pm Total Marks: 70
Instructions:
1. Attempt all questions.
2. Make suitable assumptions wherever necessary.
3. Figures to the right indicate full marks.
Q.1 (a) Write short note on performance analysis and performance measurement of an 07
algorithm.
(b) Write a selection sort algorithm and also discuss its efficiency. 07
Q.2 (a) What is Stack? List out different operation of it and write algorithm for any two 07
operation.
(b) Write a 'C' program or an algorithm to convert infix expression without parenthesis to 07
postfix expression.
OR
(b) Write user defined C function for inserting an element into circular queue. 07
Q.3 (a) What is a Queue? Write down drawback of simple queue. Also write an algorithm for 07
deleting an element from circular queue
(b) Write down advantages of linked list over array and explain it in detail. 07
OR
Q.3 (a) Write an algorithm to delete a node from doubly linked list. 07
(b) Convert A+(B*C-(D/E^F)*G) infix expression into postfix format showing stack 07
status after every step in tabular form.
Q.4 (a) Define the following terms. 1) Graph 2) Tree 3) Multi graph 4) Weighted graph 07
5) Elementary path 6) Complete Binary tree 7) Descendent node
(b) List out different traversal way of tree and demonstrate any two with example. 07
OR
Q.4 (a) Write an algorithm to delete a node from tree. 07
(b) Explain BFS and DFS in detail. 07
Q.5 (a) Explain AVL tree with example. 07
(b) List out different hash methods and explain any three. 07
OR
Q.5 (a) Write down precondition and algorithm of binary search method. 07
(b) Explain file in terms of fields, records and database. 07
*************
1
Seat No.: ________ Enrolment No.___________
Q.1 (a) 07
(i) Write algorithm to sum values in vector V and find out the execution time 04
required.
(ii) Explain the equation that finds out the address of the element of the one 03
dimensional array. Assume necessary data.
(b) 07
(i) Convert the following Polish(prefix) expression to Reverse Polish(suffix) 04
notation
a. ++abc
b. +a+bc
c. +a*bc
d. *a+bc
(ii) Does a time sharing computer use a queue or stack? Explain. 03
Q.2 (a) Write an algorithm for inserting a node and deleting a node in doubly linked linear 07
list.
(b) Write steps of procedure to insert an element to the top of the stack and remove 07
top element from a stack.
OR
(b) What is the advantage of Polish expression over infix notation? Write an 07
algorithm to convert an infix expression into reverse Polish expression.
Q.3 (a) 07
(i) Write a recursive algorithm to find factorial. 04
(ii) Which type of allocation is called linked allocation? Define singly linked 03
linear list.
(b) 07
(i) Explain the threaded storage representation for binary trees. 04
(ii) Define the inorder, postorder and preorder traversal for the following tree. 03
A
B D
C E G
OR
Q.3 (a) 07
(i) What are the advantages of circular lists over singly linked list? 04
(ii) Explain – Why doubly linked lists are much more efficient with respect to 03
deletions than singly linked lists?
1
(b) 07
(i) Define adjacency matrix. When two digraphs are considered to be 04
equivalent?
(ii) Explain the breadth first search and depth first search tree traversal on the 03
following graph.
A
B
C D E
Q.4 (a) Write an algorithm for inserting and deleting an element from queue. 07
(b) 07
(i) Define 2-3 tree. Describe the characteristic of 2-3 tree. 04
(ii) Write the characteristics of AVL tree. 03
OR
Q.4 (a) What is a circular queue? Write an algorithm for inserting and deleting an element 07
from a circular queue.
(b) 07
(i) Explain the structure of sequential file. 04
(ii) Explain the structure of indexed sequential files. 03
Q.5 (a) What is collision? Explain two broad classes of collision resolution techniques. 07
(b) Explain the binary search method. Write an algorithm for performing a binary 07
search.
OR
Q.5 (a) What is hashing? Explain hashing functions. 07
(b) Explain the multi key file organization and access methods. 07
*************
2
Seat No.: ________ Enrolment No.___________
Q.1 (a) Write a ‘C’ program for insertion sort and discuss its efficiency. 07
(b) Briefly explain various linear and non-linear data structures along with their 07
applications.
Q.2 (a) Write ‘C’ functions to: (1) insert a node at the end (2) delete a node from the 07
beginning of a doubly linked list.
(b) Write an algorithm to reverse a string of characters using stack. 07
OR
(b) Compare: (1) Linked-list and Array (2) Circular queue and Simple Queue. 07
OR
Q.3 (a) Describe: (1) Recursion (2) Priority Queue (3) Tower of Hanoi 07
(b) Write a ‘C’ functions to: (1) insert a node at beginning in singly linked list (2) 07
insert an element in circular queue.
Q.4 (a) With figure, explain the following terms: (1) Depth of a tree (2) Sibling nodes (3) 07
Strictly binary tree (4) Ancestor nodes (5) Graph (6) Minimum spanning tree (7)
Degree of a vertex
(b) Generate a binary search tree for following numbers and perform in-order and 07
post-order traversals: 50, 40, 80, 20, 0, 30, 10, 90, 60, 70
OR
Q.4 (a) Explain Right-in-threaded, left-in-threaded and full-in-threaded binary trees. 07
(b) Write Kruskal’s algorithm for minimum spanning tree and explain with an 07
example.
Q.5 (a) Describe various collision resolution techniques in hashing. 07
(b) Write an algorithm for binary search method and discuss its efficiency. 07
OR
Q.5 (a) Explain Sequential, Indexed Sequential and Random file organizations. 07
(b) Write recursive ‘C’ functions for (1) in-order (2) pre-order and (3) post-order 07
traversals of binary search tree.
*************
1
Seat No.: ________ Enrolment No.___________
Q.1 (a) What does abstract data type means? Briefly explain linear and non linear data 07
structures.
(b) Given a two dimensional array A1(1:8, 7:14) stored in row-major order with base 07
address 100 and size of each element is 4 bytes, find address of the element A1(4, 12).
Q.2 (a) Write an algorithm to implement PUSH and POP Operations on Stack. 07
(b) Write an algorithm for evaluation of postfix expression and evaluate the 07
following expression showing every status of stack in tabular form.
562-*493/+*
OR
(b) Enlist difference between recursive and iterative algorithms. Write any one 07
recursive function showing the stack contents while function call and return.
Q.3 (a) Write a program to perform insert and delete routines on a queue. 07
(b) Write advantages and disadvantages of linked list, doubly linked list and 07
circular linked list with example.
OR
Q.3 (a) Explain priority queue and dequeue. Write an algorithm/program for insert 07
routine in input restricted dequeues.
(b) Write a program to search an element in a linked list. 07
Q.4 (a) Create a Binary Search Tree for the following data and do in-order, Preorder 07
and Post-order traversal of the tree.
40, 60, 15, 4, 30, 70, 65, 10, 95, 25, 34
1
(b) Define height balanced tree. Construct a height balanced binary tree (AVL tree) 07
for the following data
32,16,44,52,78,40,12,22,02,23
*************
2
Seat No.: ________ Enrolment No.___________
MARKS
Q.1 Short Questions 14
1 Define data structure. 1
2 List operations performed on a stack. 1
3 Mention variations of the queue data structure. 1
4 What is the worst case time complexity of searching an 1
element in a list? How?
5 Mention one operation for which use of doubly linked 1
list is preferred over the singly linked list.
6 Write an algorithm/steps to traverse a singly linked list. 1
7 Define: Height of a tree. 1
8 What is the height of a complete binary with n nodes? 1
9 Write two simple hash functions. 1
10 What is a header node and what is its use? 1
11 Is Queue a priority queue? Justify. 1
12 What is the complexity of binary search algorithm? 1
13 Name two divide and conquer algorithms for sorting. 1
14 Give two applications of graphs. 1
Q.2 (a) Write an algorithm to check if an expression has 03
balanced parenthesis using stack.
(b) What is postfix notation? What are its advantages? 04
Convert the following infix expression to postfix.
A$B-C*D+E$F/G
(c) Write a C program to implement a stack with all 07
necessary overflow and underflow checks using array.
OR
(c) Write a C program to implement a circular queue using 07
array with all necessary overflow and underflow checks.
Q.3 (a) Evaluate the following postfix expression using a stack. 03
Show the stack contents.
AB*CD$-EF/G/+
A=5, B=2, C=3, D=2, E=8, F=2, G=2
(b) Perform following operations in a circular queue of 04
length 4 and give the Front, Rear and Size of the queue
after each operation.
1) Insert A, B
2) Insert C
3) Delete
4) Insert D
1
5) Insert E
6) Insert F
7) Delete
(c) Write a program to insert and delete an element after a 07
given node in a singly linked list.
OR
Q.3 (a) Explain various applications of queue. 03
(b) Differentiate between arrays and linked list. 04
(c) Create a doubly circularly linked list and write a 07
function to traverse it.
Q.4 (a) Define complete binary tree and almost complete binary 03
tree.
(b) Explain deletion in an AVL tree with a suitable 04
example.
(c) What is binary tree traversal? What are the various 07
traversal methods? Explain any two with suitable
example.
OR
Q.4 (a) Mention the properties of a B-Tree. 03
(b) Construct a binary tree from the traversals given below: 04
Inorder: 1, 10, 11, 12, 13, 14, 15, 17, 18, 21
Postorder: 1, 11, 12, 10, 14, 18, 21, 17, 15, 13
(c) What is a binary search tree? Create a binary search tree 07
for inserting the following data.
50, 45, 100, 25, 49, 120, 105, 46, 90, 95
Explain deletion in the above tree.
Q.5 (a) Insert the following elements in a B-Tree. 03
a, g, f, b, k, c, h, n, j
(b) Apply quicksort algorithm to sort the following data. 04
Justify the steps.
42, 29, 74, 11, 65, 58
(c) What is hashing? What are the qualities of a good hash 07
function? Explain any two hash functions in detail.
OR
Q.5 (a) List advantages and disadvantages of Breadth First 03
Search and Depth First Search.
(b) What is a minimum spanning tree? Explain Kruskal’s 04
algorithm for finding a minimum spanning tree.
(c) Discuss various methods to resolve hash collision with 07
suitable examples.
*************
2
Seat No.: ________ Enrolment No.___________
Q.2 (a) Write a ‘C’ program to implement a stack. Do check for overflow and 07
underflow.
(b) What is hashing? Explain the collision resolution techniques. 07
OR
(b) Define recursion. What care should be taken in writing recursive function? 07
Give a recursive solution for the problem of “Towers of Hanoi”.
Q.3 (a) Consider a circular queue of size 6. 07
Let Front =2, Rear =4, and Queue : __, L, M, N, __, __
Describe the queue as following operations are performed.
1) Add O
2) Add P
3) Delete
4) Delete
5) Add Q, R, S
6) Delete
(b) What is importance of postfix notation? Write the algorithm for converting 07
an infix expression to postfix notation.
OR
Q.3 (a) Convert the following expression to postfix notation. Show the contents of 07
the stack while conversion.
12 / (7 - 3) + 2 * (1 + 5)
(b) What is a priority queue? Discuss the array implementation of priority queue. 07
Q.4 (a) Write an algorithm to insert a node before a given node in a singly linked list. 07
Is it advantageous to use a doubly linked list for this operation? Explain.
1
Q.5 (a) A binary tree T has 9 nodes. The inorder and preorder traversals of T give the 07
following sequence of nodes.
Inorder: E A C K F H D B G
Preorder: F A E K C D H G B
Draw the tree T.
(b) What is a graph? Discuss the Adjacency Matrix and Adjacency List 07
representation of graphs with an example.
OR
Q.5 (a) Define the following with respect to a graph: 07
1) Path 2) degree 3) Cycle 4) Spanning tree 5) Directed Graph
(b) Consider the following graph: Create a minimum spanning tree using the 07
Kruskal’s algorithm.
B C D E
G H
*************
2
Seat No.: ________ Enrolment No.___________
1
(c) Write an algorithm for Insertion sort method. Explain each step with 07
an example.
Q.5 (a) Explain Breadth First Search in graphs with an example. 03
(b) Construct a binary tree from the traversals given below: 04
Inorder: 1 3 4 6 7 8 10 13 14
Preorder: 8 3 1 6 4 7 10 14 13
(c) Explain various Hash collision resolution techniques with examples. 07
OR
Q.5 (a) Explain Sequential file organizations and list its advantages and 03
disadvantages.
(b) Draw a Binary expression tree for the following and perform 04
preorder traversal: (A $ B $ C) + (D – E * F)
(c) Write Prim’s algorithm for minimum spanning tree with an 07
example.
*************
2
Seat No.: ________ Enrolment No.___________
Q.1 (a) What is data structure? Explain different types of data structures with 07
applications.
(b) Derive the formula to calculate address A[i, j] of 2-D array, for a Row-major 07
order storage representation.
A 2-D array defined as A[r, c] where 1 ≤ r ≤ 4, 5≤ c ≤ 8, requires 2 bytes of
memory for each element. If the array is stored in Row-major order form,
calculate the address of A[3,7] given the Base address as 2000.
Q.2 (a) Discuss and compare array and linked list. 07
(b) Discuss importance of hashing. Also discuss one of the method of hashing with 07
an example.
OR
(b) Discuss the structure of sequential and indexed file organization. 07
Q.3 (a) Write algorithm OR code for PUSH, POP and DISPLAY function of the 07
STACK.
(b) Convert the following infix expression to postfix form using Stack. 07
(( A – (B + C)) × D) / (E + F)
OR
Q.3 (a) Write algorithm OR code for INSERT, DELETE and DISPLAY function of the 07
QUEUE.
(b) What is a priority queue? Discuss the array implementation of priority queue. 07
Q.4 (a) Write C code to insert a node at the end of a doubly link list. 07
(b) Write an algorithm to merge two simple link lists having initial address L1 and 07
L2 respectively. Also write algorithm to display the list.
OR
Q.4 (a) Write algorithm OR code for DELETE and DISPLAY functions of Circular 07
Link List.
(b) Write C code for the following operations for a simple link list. 07
i. Reverse : to reverse the link list
ii. Max : to find the largest element from the link list.
Q.5 (a) Write a non-recursive algorithm for Preorder traversal of a binary tree 07
(b) What is a sparse matrix? Explain memory representation of a sparse matrix. 07
OR
Q.5 (a) Discuss DFS and BFS. 07
(b) Discuss Inorder and Postorder traversal of a binary tree. 07
*************
1
Seat No.: ________ Enrolment No.___________
GUJARAT TECHNOLOGICAL UNIVERSITY
BE - SEMESTER–III(New) • EXAMINATION – WINTER 2016
Subject Code:2130702 Date:02/01/2017
Subject Name:Data Structure
Time:10:30 AM to 01:00 PM Total Marks: 70
Instructions:
1. Attempt all questions.
2. Make suitable assumptions wherever necessary.
3. Figures to the right indicate full marks.
MARKS
Q.1 Explain the following terms in brief 14
1 Primitive data structure
2 Non-primitive data structure
3 Linear data structure
4 Non-linear data structure
5 Recursion
6 Time complexity of an algorithm
7 Double-ended queue
8 Priority queue
9 Circular linked list
10 Complete binary tree
11 2-3 tree
12 Minimum spanning tree
13 Degree of vertex
14 Hash collision
Q.2 (a) Write a pseudo-code for PUSH and POP operations of 03
stack.
(b) What is prefix notation? Convert the following infix 04
expression into prefix.
A+B–C*D*E$F$G
(c) Write an algorithm to perform various operations (insert, 07
delete and display) for simple queue.
OR
(c) Write differences between simple queue and circular 07
queue. Write an algorithm for insert and delete operations
for circular queue.
Q.3 (a) Convert the following infix expression into postfix. 03
A+B–C*D*E$F$G
(b) Write algorithm(s) to perform INSERT_FIRST (to insert 04
a node at the first position) and REVERSE_TRAVERSE
(to display the data in nodes in reverse order) operations
in doubly linked list.
(c) Write a ‘C’ program to implement stack using linked list. 07
OR
Q.3 (a) Enlist and briefly explain various applications of stack. 03
(b) Discuss various rehashing techniques. 04
(c) Write ‘C’ functions to implement INSERT_FIRST (to 07
insert a node at the first position), DELETE_FIRST (to
delete a node from the first position), DELETE_LAST
(delete a node from the last position) and TRAVERSE (to
display the data in nodes) operations in circular linked
list.
1
Q.4 (a) Write an algorithm for Binary search method. 03
(b) Write a ‘C’ program for Bubble sort. 04
(c) Sort the following numbers using (i) Selection sort (ii) 07
Quick sort:
10 50 0 20 30 10
OR
Q.4 (a) Write a ‘C’ function for Selection sort. 03
(b) Write an algorithm for Quick sort. 04
(c) Explain Depth First Search and Breadth First Search in 07
graphs with an example.
Q.5 (a) Draw a binary expression tree for the following and 03
perform preorder traversal for the same:
(A + B $ C) + (D + E * F)
(b) Construct a binary search tree for the following and 04
perform inorder and postorder traversals:
5 9 4 8 2 1 3 7 6
(c) Write ‘C’ functions for: inserting a node, postorder 07
traversal and counting total number of nodes for binary
search tree.
OR
Q.5 (a) Explain AVL trees. 03
(b) Construct a binary search tree from the following 04
traversals:
Inorder: 3 4 5 6 7 9 17 20 22
Preorder: 9 4 3 6 5 7 17 22 20
(c) Write Kruskal’s algorithm for minimum spanning tree with 07
an example.
*************
2
Seat No.: ________ Enrolment No.___________
MARKS
Q.1 Short Questions 14
1 Arithmetic expression evaluation is an explanation of which 1
data structure?
2 How many stacks are needed to implement a queue. Consider 1
the situation where no other data structure like arrays, linked
list is available.
3 A graph containing only isolated nodes is called a ___. 1
4 What is the 2’s complement representation for integer 5 in 1
modulo 16?
5 What is the result of 7+7 using 2’s complement representation 1
and modulo 16 arithmetic.
6 In which type of tree, each leaf node is kept at the same 1
distance from root?
7 What is the reverse polish notation for infix expression a / b
*c ? 1
8 What does the following function do for a given Linked List 1
with first node as head?
void fun1(struct node* head)
{
if(head == NULL)
return;
fun1(head->next);
printf("%d ", head->data);
}
9 Which of the traversal technique outputs the data in sorted 1
order in a Binary Search Tree?
10 What is common in inorder, preorder and postorder traversal? 1
1
Q.2 (a) Write an algorithm for finding average of given numbers. 03
Calculate time complexity.
(b) Given Inorder and Preorder traversal, find Postorder traversal. 04
Inorder traversal = {4, 2, 5, 1, 3, 6}
Preorder traversal = {1, 2, 4, 5, 3, 6}
OR
(c) Insertion sequence of names is 07
Norma, Roger,John,Bill,Leo,Paul, Ken and Maurice
(i) Show the behavior of creating a lexically ordered
binary tree.
(ii) Insert Kirk. Show the binary tree.
(iii)Delete John. Show the binary tree.
Q.3 (a) Write an algorithm to return the value of ith element from top 03
of the stack.
(b) Write an algorithm for inserting an element in a stack, 04
removing an element from stack .
(c) Write algorithm for inserting and deleting an element in 07
circular queue.
OR
Q.3 (a) Consider the expression v1*v2-(v3+v4^v5). Show the tree 03
corresponding to the expression.
(b) What is an ordered tree? What is forest? 04
(c) Explain the structure of indexed sequential file. 07
Q.4 (a) Consider singly linked storage structures,Write an algorithm 03
which inserts a node into a linked linear list in a stack like
manner.
(b) How open addressing can be used for collision resolution? 04
*************
2
Seat No.: ________ Enrolment No.___________
Q.1 (a) What does abstract data type means? Briefly explain linear and non linear data 07
structures.
(b) Explain PUSH and POP operation of the stack with algorithm. 07
Q.2 (a) Convert following infix expressions to the postfix expressions. Shows stack 07
trace.
A/B$C+D*E/F-G+H
(A+B)*D+E/(F+G*D)+C
(b) Write an algorithm to convert infix to postfix expression and explain it with 07
example.
OR
(b) Write a Program to perform insert and delete operations on a circular Queue. 07
Q.3 (a) Define recursion. What care should be taken in writing recursive function? Give 07
a recursive solution for the problem of “Towers of Hanoi”.
(b) Write an algorithm to insert and delete a node in Doubly Linked List. 07
OR
Q.3 (a) Differentiate between stack & queue. Also explain priority queue with example. 07
(b) Write a program to search an element in a linked list. 07
Q.4 (a) Create a Binary Search Tree for the following data and do in-order, Preorder and 07
Post-order traversal of the tree.
40, 60, 15, 4, 30, 70, 65, 10, 95, 25, 34
(b) Define the following with example : 07
Strictly binary tree
Complete binary tree
OR
Q.4 (a) How graph can be represented? Write an algorithm for Breadth First Search 07
Traversal of a Graph.
(b) What is an AVL tree? Explain the different types of rotations used to create an 07
AVL tree with suitable examples.
Q.5 (a) What is hashing? Explain hashing functions. 07
(b) Write a short note on inverted key file organization 07
OR
Q.5 (a) Define Hash Clash. Explain Primary Clustering, secondary clustering, rehashing 07
and double hashing.
(b) Write a short note on indexed file organization. 07
*************
1
Seat No.: ________ Enrolment No.___________
GUJARAT TECHNOLOGICAL UNIVERSITY
BE - SEMESTER–III (NEW) - EXAMINATION – SUMMER 2018
Subject Code:2130702 Date:21/05/2018
Subject Name:Data Structure
Time:10:30 AM to 01:00 PM Total Marks: 70
Instructions:
1. Attempt all questions.
2. Make suitable assumptions wherever necessary.
3. Figures to the right indicate full marks.
MARKS
Q.1 (a) Differentiate between linear and non linear data structures. 03
(b) Discuss the variations of a queue. 04
(c) Write an algorithm to convert an infix expression to postfix expression. 07
Show the working of the algorithm for the following expression.
A+B*C/D$E-(F*G)
Q.2 (a) Evaluate the following postfix expression using a stack. Show the steps. 03
2 $ 3 + 5 * 2 $ 2 – 12 $ 6
(b) Consider the stack S of characters, where S is allocated 8 memory cells. 04
S: A,C,D, F, K, _, _, _
Describe the stack as the following operations take place.
Pop(), Pop() ,Push(L), Push(P), Pop(), Push(R), Push (S), Pop()
(c) Write a program to implement queue and check for boundary conditions. 07
OR
(c) Write a program to implement a circularly linked list. 07
Q.3 (a) List the advantages of a doubly linked list over singly linked list. 03
(b) Write an algorithm to swap two nodes, n and n+1, in a singly linked list. 04
(c) Perform inorder, postorder and preorder traversals for the following 07
binary tree.
Q.5 (a) What is the complexity of the quick sort algorithm on sorted data? 03
Justify your answer.
(b) What is hashing? Explain hash collision and any one collision resolution 04
technique.
(c) Explain the difference between insertion sort and selection sort with an 07
example. What is the time complexity of these algorithms? How?
OR
Q.5 (a) List the qualities of a good hash function. 03
(b) Explain two hash functions. 04
(c) Apply merge sort algorithm for the following data and show the steps. 07
66, 33, 40, 22, 55, 88, 11, 80, 20, 50, 44, 77, 30
*************
2
Seat No.: ________ Enrolment No.___________
Q.1 (a) What is Recursion? Write a pseudocode in ‘C’ language to find the 03
multiplication of two natural numbers.
(b) Differentiate between Stack and Queue. 04
(c) Write algorithms for Push and Pop operations on a stack. 07
Q.2 (a) Convert Infix Expression A ^ B * C - D + E / F / (G + H) into Postfix 03
expression using stack.
(b) Explain average case timing analysis for Search Algorithm. 04
(c) Write an algorithms to convert Infix Expression(without parenthesis) into 07
Postfix Expression
OR
(c) Write algorithms for Insert and Delete operation in Circular Queue. 07
Q.3 (a) Evaluate the Postfix Expression 6 2 3 + - 3 8 2 / + * 2 $ 3 + using Stack. 03
(b) Write an algorithm for insertion of node at last position in Liner Linked List. 04
(c) Create a Binary Search Tree for the following data and do Inorder, Preorder 07
and Postorder traversal of the tree.
45, 70,30, 60, 15,75,35,55,20,85,80
OR
Q.3 (a) Explain Priority Queue? 03
(b) Write an algorithm for deletion of node in Liner Linked List. 04
(c) What is Binary Search Tree? Construct a binary search tree for the 07
following elements
11,6,14,8,12,15,16,7,9,23
Q.4 (a) Write an algorithm for Bubble sort. 03
(b) Write an algorithm for insertion of a node in Doubly Linked List. 04
(c) What is hashing? Explain Different Hashing techniques in brief. 07
OR
Q.4 (a) Write an algorithm for Selection sort. 03
(b) Write an algorithm for deletion of a node in Doubly Linked List. 04
(c) What is hashing? Explain hash clash and its resolving techniques. 07
*************
1
Seat No.: ________ Enrolment No.___________
Q.1 (a) Define Data Structure and differentiate between linear and nonlinear 03
data structures.
(b) Write a pseudocode for PUSH and POP operations of stack. 04
(c) Write algorithm for inserting an element in circular queue and deleting 07
a node from a singly linked list.
Q.2 (a) Illustrate the working of priority queue with suitable example. 03
(b) Write recursive algorithm to compute factorial of a given number. 04
Which data structure can be used to implement this algorithm?
(c) Sort the following numbers in ascending order by applying quick sort. 07
29 15 11 82 22 17 53 57 4 8
OR
(c) “If no interchanges occurred, then all the elements must be sorted and 07
no further passes are required.” Which sorting technique works on this
principal? Apply the same sorting technique on the following data to
sort them in ascending order.
11, 15, 13, 14, 2, 8, 10
Q.3 (a) Evaluate the following postfix expression in tabular form showing 03
stack after every step.
7 6 + 4 * 4 10 + - 5 +
(b) Write the algorithm for binary search. 04
(c) Explain the working of the Prim’s algorithm with suitable example. 07
OR
Q.3 (a) List the advantages of a doubly linked list over singly linked list. 03
(b) List out graph traversal techniques & explain any one using suitable 04
example.
(c) Apply Djkstra’s algorithm on following graph with Node A as the 07
starting node.
*************
2
Seat No.: ________ Enrolment No.___________
Q.1 (a) Define primitive and non-primitive data types with example. 03
(b) Differentiate linear and non-linear data structures. 04
(c) Write algorithms for PUSH and POP stack operations. 07
Q.4 (a) Prove that a binary tree with 20 nodes have 21 null branches. 03
(b) Write a recursive algorithm for preorder traversal of binary tree. 04
(c) Describe Prim’s minimum spanning tree algorithm with example. 07
OR
Q.4 (a) Show the resultant BST after applying following operations in sequence 03
on given tree. Delete 8 b) Insert 9 c) Delete 7
(b) Enlist and describe different ways for representing graph data structure 04
with example.
(c) Show the steps of BFS and DFS traversal for following graph starting 07
from vertex 2. Consider adjacency list is sorted in ascending order.
1
Q.5 (a) Write an algorithm for linear searching. 03
(b) Describe indexing structure for index file. 04
(c) Write an algorithm for merge sort. Show the steps of its working with 07
sample data.
OR
Q.5 (a) Define hash function. Describe any two hash methods with example. 03
(b) Write an algorithm for binary searching. 04
(c) Apply bubble sort on following data and show all steps. 07
123, 34, 65, 105, 27, 79, 12, 10, 125, 156
*************
2
Seat No.: ________ Enrolment No.___________
Marks
Q.1 (a) Discuss various types of data structures with 03
example.
(b) What is hash function used for? Give one example 04
of a hash function.
(c) What is time and space analysis? State and explain 07
time analysis for linear search and binary search
method.
****************
2
Seat No.: ________ Enrolment No.___________
Marks
2
Seat No.: ________ Enrolment No.___________
Q.5 (a) Construct a binary tree from the traversals given below: 03
Inorder: 0, 10, 20, 30, 40, 50, 60, 70, 80, 90
Preorder: 50, 10, 0, 40, 30, 20, 90, 80, 60, 70
(b) Write a short on height balanced and weight balance tree. 04
(c) Explain insertion operation in the 2-3 tree: (i) if the parent has 2 children 07
and (ii) if the parent has 3 children.
Q.6 (a) Construct a binary search tree from the traversals given below: 03
Inorder: 20, 30, 35, 40, 70, 80, 90, 100
Postorder: 20, 35, 30, 80, 70, 100, 90, 40
(b) Write a short on breadth first search and depth first search in graph. 04
(c) Explain AVL tree with example. 07
1
Q.7 (a) Explain binary search with example. 03
(b) Write a C program for bubble sort. 04
(c) Explain the techniques for collision-resolution in Hashing with example. 07
********************
2
Seat No.: ________ Enrolment No.___________
Marks
Q.1 (a) Compare array and linked list. 03
(b) Compare primitive and non primitive data types. datastructures 04
(c) Write an algorithm to perform insert and delete operations on simple queue. 07
Q.2 (a) Search the number 50 from the given data using binary search technique. 03
Illustrate the searching process.
10, 14, 20, 39, 41, 45, 49, 50, 60
(b) Apply merge sort algorithm to the following elements. 20, 10, 5, 15, 25, 30, 04
50, 35
(c) Write a ‘C’ program for bubble sort. 07
Q.5 (a) Define: 1. Acyclic graph 2. Leaf node 3. Complete binary tree 03
(b) For following expressions, construct the corresponding binary tree. 04
1. A+B/C*D-E
2. ((A+B)-(C*D))%((E^F)/(G-H))
(c) How are graphs represented inside a computer’s memory? Which method 07
do you prefer and why?
1
Q.8 (a) Give a brief note on indexing. 03
(b) Build a chained hash table of 10 memory locations. Insert the keys 131, 3, 04
4, 21, 61, 24, 7, 97, 8, 9 in hash table using chaining. Use h(k) = k mod m.
(m=10)
(c) Consider the hash table of size 10. Using quadratic probing, insert the keys 07
72, 27, 36, 24, 63, 81, and 101 into hash table. Take c1=1 and c2=3.
**********************
2
Seat No.: ________ Enrolment No.___________
1
Seat No.: ________ Enrolment No.___________
Q.3 (a) Write user defined ‘C’ function to insert node at a specific location in singly 03
linked list.
(b) Write user defined ‘C’ function to delete node from end in circular linked 04
list.
(c) Write a ‘C’ program to implement queue using linked list. 07
OR
Q.3 (a) Write user defined ‘C’ function to insert node at the end in circular linked list. 03
(b) Write user defined ‘C’ function to delete node from a specific location in 04
doubly linked list.
(c) Write a ‘C’ program to implement stack using linked list. 07
Q.4 (a) Construct a binary tree from the traversals given below: 03
Inorder: D, B, A, E, G, C, H, F, I
Preorder: A, B, D, C, E, G, F, H, I
(b) Write a short on AVL tree. 04
(c) Explain the concept of B-tree with suitable example and list its applications. 07
OR
Q.4 (a) Construct a binary search tree from the following numbers. 03
38, 13, 51, 10, 12, 40, 84, 25, 89, 37, 66, 95
(b) Explain BFS and DFS. 04
(c) Explain B+ tree with example. 07
**********
2
Seat No.: ________ Enrolment No.___________
Q.3 (a) Explain the working of priority queue with suitable example. 03
(b) Write an algorithm for insertion of a new node at last position in Singly 04
Linked List.
(c) Write a C program to implement simple queue and check for boundary 07
conditions.
OR
Q.3 (a) List the advantages of doubly linked list over singly linked list. 03
(b) Write an algorithm for deletion of a specific node from the Singly 04
Linked List.
(c) Write a C program to implement circular queue with insertion and 07
deletion operations.
Q.4 (a) How can you represent a Binary Tree in memory using array? 03
(b) Given Inorder and Preorder traversal, find Postorder traversal. Inorder: 04
YBKCFAGXEDHZ
Preorder: G B Y A C K F X D E Z H
(c) What is a binary search tree? Create a binary search tree for the 07
following data. 14, 10, 17, 12, 10, 11, 20, 12, 18, 25, 20, 8, 22, 11, 23
Explain deleting node 20 in the resultant binary search tree.
OR
Q.4 (a) Write algorithms for the inorder, preorder and postorder traversal of the 03
binary tree.
1
(b) Draw a Binary expression tree for the following and perform preorder 04
traversal: a * ( b + c ) + ( d * e ) / f + g * h
(c) Insert the following letters into an empty B-tree of order 5: C N G A H 07
EKQMFWLTZDPRXYS
*************
2
Seat No.: ________ Enrolment No.___________
Q.2 (a) What is Sparse matrix? Write efficient vector representation of following 03
Sparse matrix.
1 0 0
0 2 0
0 0 3
(b) What is the worst case complexity of binary search? Write an algorithm for 04
binary search.
(c) Create Binary Search Tree for following Data and write pre-order traversal, in- 07
order traversal and post-order traversal of the constructed tree.
10 15 28 09 39 31 30 14 07 08
OR
(c) Create AVL tree for following Data and write pre-order traversal of the 07
constructed tree.
10 15 28 09 39 31 30 14 07 08
Q.3 (a) Write c program for bubble sort. 03
(b) Write algorithm to insert into simple queue and mention the limitation of 04
simple queue?
(c) Find the minimum spanning tree of following graph using Kruskal’s method. 07
OR
1
Q.3 (a) Write c program for selection sort. 03
(b) Write algorithm to delete from circular queue and mention the advantage of 04
circular queue over simple queue?
(c) Find the minimum spanning tree of the following graph using prim’s method. 07
Q.4 (a) What is priority queue? Is simple queue is anyhow priority queue? Explain 03
your answer.
(b) Write C program to find the Fibonacci sequence of n terms using recursion. 04
(c) Explain DFS and BFS with appropriate example. 07
OR
Q.4 (a) What is linked list? States the advantages of linked list over array. Also list 03
various types of the linked list.
(b) Write recursive solution for tower of Hanoi. How many moves require for 04
transferring three discs?
(c) Explain Dijkstra’s shortest path algorithm with appropriate example 07
2
Seat No.: ________ Enrolment No.___________
Q.1 (a) What is DS? Explain data structure and its types. 03
(b) Explain Tower of Hanoi with example. 04
(c) Write algorithms to insert, and delete elements in queue 07
Q.2 (a) Construct Binary Tree where the preorder traversal is 1,2,4,5,3,6,8,9,7 & 03
postorder is 4,5,2,8,9,6,7,3,1.
(b) Construct an AVL Tree by inserting numbers from 1 to 8. 04
(c) What is stack? Explain operations on stack in detail. 07
OR
(c) Explain tree traversal in detail with example. 07
Q.4 (a) List all asymptotic notations and explain any one of it. 03
(b) List and explain linked list applications. 04
(c) What is doubly linked list? Write Algorithm for insertion and deletion in 07
doubly linked list.
OR
Q.4 (a) What is file? Explain types of files. 03
(b) Convert the following infix expressions to their prefix. 04
(A^B*C-D+E/F/(G+H))
(c) Explain Prim’s & Kruskal’s algorithm with suitable example 07