Question Bank
Question Bank
Question Bank
Question Bank
Semester: III
Session: 2023-24(ODD)
Unit 2
S.No. Questions Marks CO
1. Evaluate the following prefix expression " ++ 26 + - 1324" 4 CO2
2. Convert the following infix expression to post fix notation 4 CO2
((a+2)*(b+4))-1 (Similar types can be asked).
3. How is it possible to insert different type of elements in 2 CO2
stack?
4. Stack can be described as a pointer. Explain. 2 CO2
5. Which data structure is needed to convert infix notations to 10 CO2
post fix notations?
6 Parenthesis are never needed in prefix or postfix 10 CO2
expressions. Why?
7 Minimum number of queues needed to implement the 10 CO2
priority queue?
8 Write an algorithm to evaluate a postfix expression. Execute 10 CO2
your algorithm using the following postfix expression as
your input: a b + c d+*f.
9 What are circular queues? Write down routines for inserting 10 CO2
and deleting elements from a circular queue implemented
using arrays.
10. In which data structure, elements can be added or removed 10 CO2
at either end, but not in the middle?
11. What are the methods available in storing sequential files? 10 CO2
12. A stack is to be implemented using an array. The associated 10 CO2
declarations are:
int stack [100];
int top = 0;
Unit 3
S.No. Questions Marks CO
1. Write an algorithm to sort a given list using Quick sort 6 CO3
method. Describe the behaviour of Quick sort when input is
already sorted.
2. Sort the following list using Heap Sort 66, 33, 40, 20, 50, 6 CO3
88, 60, 11, 77, 30, 45, 65
3. Define graph, adjacency matrix, adjacency list, hash 6 CO3
function, sparse matrix, reachability matrix.
4. What is quick sort? Sort the following array using quick sort 6 CO3
method. 24 56 47 35 10 90 82 31.
5. How many key comparisons and assignments an insertion 10 CO3
sort makes in its worst case?
6 Create a heap with following list of keys: 8, 20, 9, 4, 15, 10, 10 CO3
7, 22, 3, 12
7 The following values are to be stored in a hash table: 25, 42, 10 CO3
96, 101, 102, 162, 197
8 Describe how the values are hashed by using division 10 CO3
method of hashing with a table size of 7. Use chaining as the
method of collision resolution.
9 Describe insertion sort with a proper algorithm. What is the 10 CO3
complexity of insertion sort in the worst case?
10. How will you represent a max-heap sequentially? Explain 10 CO3
with an example.
11. Write an algorithm to insert an element to a max-heap that is 10 CO3
represented sequentially.
12. What do you mean by hashing? Explain any five popular 10 CO3
hash functions.
13 What is the best-case complexity of quick sort and outline 10 CO3
why it is so? How could its worst-case behaviour arise?
14. Apply the merge sort algorithm to sort the following 10 CO3
elements in ascending order. 13, 16, 10, 11, 4, 12, 6, 7.
Discuss the time and space complexity of merge sort?
15. Apply the quick sort algorithm to sort 15, 22, 30, 10, 15, 64, 10 CO3
1, 3, 9, 2. Is it a stable sorting? Justify.
16. Write heap sort algorithm. Analyze the running time of your 10 CO3
algorithm.
17. The keys 12, 17, 13, 2, 5, 43, 5 and 15 are inserted into an 10 CO3
initially empty hash table of length 15 using open
addressing with hash function h(k)=k mod 10 and linear
probing. Show the resultant hash table?
18. Differentiate between linear and quadratic probing 10 CO3
techniques, with example.
19. Using the bubble sort algorithm, find the number of swaps 10 CO3
(interchange) required to sort: 5, 10, 15, 55, 45, 35, 60, 75,
70
20. Write algorithm of insertion sort. Implement the same on the 10 CO3
following numbers; also calculate its time complexity. 13,
16, 10, 11, 4, 12, 6, 7
21. Explain the following as a short note: 10 CO3
a) Internal Sorting vs External Sorting with example
b) Stable Sorting vs Unstable Sorting with example
c) In-Place Sorting vs Out-Place Sorting with
example
22. Given input {4371, 1323, 6173, 4199, 4344, 9679, 1989} 10 CO3
and a hash function h(X) = X (mod 10) Calculate the
memory location of each key and set them at the memory
from 1 to 10.
i. Hash table with using linear probing and
ii. Hash table with quadratic probing.
iii. Hash table with second hash function
h2 (x) = 7 − (x mod 7).
23. Discuss the worst case and best case time complexity of 10 CO3
Binary search.
24. Bubble sort algorithm is inefficient because it continues 10 CO3
execution even after an array is sorted by performing
unnecessary comparisons. Therefore, the number of
comparisons in the best and worst cases are the same.
Modify the algorithm in such a fashion that it will not make
the next pass when the array is already sorted.
25. Write an algorithm for merge sort with suitable example 10 CO3
Unit 4
S.No. Questions Marks CO
1. Given a set of input representing the nodes of a binary tree, 6 CO4
write a non recursive algorithm that must be able to output
the three traversal orders.
2. Write an algorithm for checking validity of the input, i.e., 6 CO4
the program must know if the input is disjoint, duplicated
and has a loop.
3. What is a Binary Search Tree (BST)? Make a BST for the 6 CO4
following sequence of numbers 45, 36, 76, 23, 89, 115, 98,
39, 41, 56, 69, 48 Traverse the tree in Preorder, Inorder and
postorder.
4. Two Binary Trees are similar if they are both empty or if 6 CO4
they are both nonempty and left and right sub trees are
similar. Write an algorithm to determine if two Binary Trees
are similar.
5. The degree of a node is the number of children it has. Show 10 CO4
that in any binary tree, the number of leaves is one more
than the number of nodes of degree 2.
6 Taking a suitable example explains how a general tree can 10 CO4
be represented as a Binary Tree.
7 What is the maximum total number of nodes in a tree that 10 CO4
has N levels? Note that the root is level (zero).
8 Write the non-recursive algorithm to traverse a tree in 10 CO4
preorder.
9 What are expression trees? Represent the following 10 CO4
expression using a tree. Comment on the result that you get
when this tree is traversed in Preorder, Inorder and
postorder. (a-b) / ((c*d)+e).
10. Taking a suitable example explains how a general tree can 10 CO4
be represented as a Binary Tree.
11. How many different binary trees and binary search trees can 10 CO4
be made from three nodes that contain the key values 1, 2 &
3?
12. How will inorder, preorder and postorder traversals print the 10 CO4
elements of a tree?
13 Which one is faster? A binary search of an orderd set of 10 CO4
elements in an array or a sequential search of the elements.
14. Write a non-recursive algorithm to traverse a binary tree in 10 CO4
inorder.
15. Construct a binary tree whose nodes in inorder and preorder 10 CO4
are given as follows:
Inorder : 10, 15, 17, 18, 20, 25, 30, 35, 38, 40, 50
Preorder: 20, 15, 10, 18, 17, 30, 25, 40, 35, 38, 50.
19. Construct a complete binary tree with depth 3 for this tree 10 CO4
which is maintained in memory using linked representation.
Make the adjacency list and adjacency matrix for this tree.
20. Construct the binary tree for the following sequence of 10 CO4
nodes in preorder and inorder respectively.
Preorder: G, B, Q, A, C, K, F, P, D, E, R, H
Inorder: Q, B, K, C, F, A, G, P, E, D, H, R
21. What is a height balanced tree? Explain how the height is 10 CO4
balanced after addition/deletion of nodes in it?
22. Let a binary tree ‘T’ be in memory. Write a procedure to 10 CO4
delete all terminal nodes of the tree.
23. Consider the following eight numbers 50, 33, 44, 22, 77, 35, 10 CO4
60 and 40. Display the construction of the binary by
inserting the above numbers in the given order.
24. If the Inorder of a binary tree is B,I,D,A,C,G,E,H,F and its post 10 CO4
order is I,D,B,G,C H,F,E,A then draw a corresponding binary tree
with neat and clear steps from above assumption.
25. Insert the following sequence of elements into an AVL tree, 10 CO4
starting with empty tree 71,41,91,56,60,30,40,80,50,55 also find
the minimum array size to represent this tree.
26. Write Short notes of following: 10 CO4
(a) Extended Binary Trees
(b) Complete Binary Tree
(c) Threaded Binary Tree.
27. What is the difference between a binary search tree (BST) and 10 CO4
heap? For a given sequence of numbers, construct a heap and a
BST. 34, 23, 67, 45, 12, 54, 87, 43, 98, 75, 84, 93, 31
28. What is a B-Tree? Generate a B-Tree of order 4 with the 10 CO4
alphabets (letters) arrive in the sequence as follows:
AGFBKDHMJESIRXCLNTUP
29. Can you find a unique tree when any two traversals are given? 10 CO4
Using the following traversals construct the corresponding binary
tree:
INORDER: H K D B I L E A F C M J G
PREORDER: A B D H K E I L C F G J M.
Also find the Post Order traversal of obtained tree.
30. Consider the following AVL Tree and insert 2, 12, 7 and 10 as 10 CO4
new node. Show proper rotation to maintain the tree as AVL.
31. What maximum difference in heights between the leafs of a AVL 10 CO4
tree is possible?
a) log(n) where n is the number of nodes
b) n where n is the number of nodes
c) 0 or 1
d) at most 1
32. Define AVL Trees. Explain its rotation operations with examples. 10 CO4
Construct an AVL Trees with the values 10 to 1 numbers into an
initially empty binary tree.
Unit 1
S.No. Questions Marks CO
1. Write an algorithm for BFS. 4 CO5
2. What are the different ways of representing a graph? Represent 4 CO5
the following graph using those ways.
3. Write an algorithm which does depth first search through an 6 CO5
un-weighted connected graph. In an un-weighted graph, would
breadth first search or depth first search or neither find a shortest
path tree from some node? Why?
4. Which are the two standard ways of traversing a graph? Explain 4 CO5
them with an example of each.
5. Explain Dijkstra’s algorithm for finding the shortest path in a 6 CO5
given graph.
6 Explain Depth First Search (DFS) algorithm. Find all possible 6 CO5
DFS and BFS of below given graph started at node “a”.
a)Find the adjacency Matrix A of G.
b)Find the Path Matrix of G. Is G Strongly connected.
11. Describe Dijkstra’s algorithm for finding shortest path. Describe 8 CO5
its working for the graph given below.
12. Apply Prim’s and Kruskal’s algorithm to find the minimum 8 CO5
spanning tree on given graph.