Sree Saraswathi Thyagaraja College (Autonomous), Pollachi
Sree Saraswathi Thyagaraja College (Autonomous), Pollachi
MCA Department
Question Bank – Advanced Data Structures and Algorithms
Unit – I
Section – A (1 Mark)
A linear collection of data elements where the linear node is given by means of pointer is called?
a) Linked list
b) Node list
c) Primitive list
d) None
Answer:A
A variant of the linked list in which none of the node contains NULL pointer is?
a) Singly linked list
b) Doubly linked list
c) Circular linked list
d) None
Answer: C
In a linked list the .......... field contains the address of next element in the list.
A.Link field
B.Next element field
C.Start field
D.Info field
Answer: B
LLINK is the pointer pointing to the ...
A.successor node
B.predecessor node
C.head node
D.last node
Answer:B
A linear list in which the pointer points only to the successive node is ......
A.singly linked list
B.circular linked list
C.doubly linked list
D.none of the above
Answer:A
The data structure required to check whether an expression contains balanced parenthesis is?
a) Stack
b) Queue
c) Array
d) Tree
ANSWER: a) Stack
What data structure would you mostly likely see in a non recursive implementation of a recursive
algorithm?
a) LinkList
b) Stack
c) Queue
d) Tree
ANSWER: b) Stack
The process of accessing data stored in a serial access memory is similar to manipulating data on a
------?
a) Heap
b) Binary Tree
c) Array
d) Stack
ANSWER: d) Stack
A linear list of elements in which deletion can be done from one end (front) and insertion can take
place only at the other end (rear) is known as a ?
a) Queue
b) Stack
c) Tree
d) Linked list
ANSWER: a) Queue
A queue is a ?
a) FIFO (First In First Out) list
b) LIFO (Last In First Out) list.
c) Ordered array
d) Linear tree
ANSWER: a) FIFO (First In First Out) list
If the elements “A”, “B”, “C” and “D” are placed in a queue and are deleted one at a time, in what
order will they be removed?
a) ABCD
b) DCBA
c) DCAB
d) ABCD
ANSWER: a) ABCD
Section – B (5 Mark)
Write a program to print out the elements of a singly linked list.
Given two sorted lists, L1 and L2,write a procedure to compute L1 L2 using only the
basic list operation.
Write a program to evaluate a postfix expression.
Write a program to convert postfix expression in to infix.
Write a routine to implement queues using linked list
Write a routine to implement queues using Array.
Explain the procedure to insert a new node in the
(a) Beginning
(b) End of the list
Write an algorithm for the following in doubly linked list.
(i) inserting a node to the left.
(ii) Deleting a node.
Explain the cursor implementation of linked list.
Explain the following algorithm of a circular linked list.
(a) inset the node at the beginning
(b) delete a node from beginning
Write a routine to implement stack using
(a) array
(b) linked list
Write a routine to implement polynomial ADT.
Section – C (8 Mark)
Explain in detail about Arrays?
Discuss in detail about structures in c.
What is a Stack? Explain its operations with example.
Write the algorithm for converting infix expression to postfix expression.
What is a Queue? Explain its operations with example.
Explain any two applications of stack.
Write an algorithm to perform the following operation on a singly linked list.
(i) Insert new node at the beginning of list.
(ii) Insert new node at Middle.
(iii) Delete a node in the middle and last.
(iv) Count the number of nodes.
Write an algorithm to perform the following operation on a doubly linked list.
(v) Insert new node at the beginning of list.
(vi) Insert new node at Middle.
(vii) Delete a node in the middle and last.
(viii) Count the number of nodes.
Explain the Linear linked Implementation of Stack and Queue.
Explain the Insertion and Deletion algorithm for Circular linked List.
Explain the operations of Priority Queue.
Write the algorithm to merge any two Linked list.
Write an algorithm that takes the first node in a linked list, Reverse it and return the first
node in the resulting linked list without recursion and with recursion.
Implement a circular Queue in C using arrange to perform insertion and deletion
operations.
Convert the following Infix Expression to postfix using stack.
A*B-(C+D)+E
Explain Polynomial addition operation using array.
Unit – II
Section – A (1 Mark)
The height of a BST is given as h. Consider the height of the tree as the no. of edges in the longest
path from root to the leaf. The maximum no. of nodes possible in the tree is?
a) 2h-1 -1
b) 2h+1 -1
c) 2h +1
d) 2h-1 +1
ANSWER: B
The no of external nodes in a full binary tree with n internal nodes is?
a) n
b) n+1
c) 2n
d) 2n + 1
ANSWER: B
The difference between the external path length and the internal path length of a binary tree with
n internal nodes is?
a) 1
b) n
c) n + 1
d) 2n
ANSWER: D
Suppose a binary tree is constructed with n nodes, such that each node has exactly either zero or
two children. The maximum height of the tree will be?
a) (n+1)/2
b) (n-1)/2
c) n/2 -1
d) (n+1)/2 -1
ANSWER: B
Suppose we have numbers between 1 and 1000 in a binary search tree and want to search for the
number 363. Which of the following sequence could not be the sequence of the node examined?
a) 2, 252, 401, 398, 330, 344, 397, 363
b) 924, 220, 911, 244, 898, 258, 362, 363
c) 925, 202, 911, 240, 912, 245, 258, 363
d) 2, 399, 387, 219, 266, 382, 381, 278, 363
ANSWER: C
In full binary search tree every internal node has exactly two children. If there are 100 leaf nodes
in the tree, how many internal nodes are there in the tree?
a) 25
b) 49
c) 99
d) 101
ANSWER: C
Which type of traversal of binary search tree outputs the value in sorted order?
a) Pre-order
b) In-order
c) Post-order
d) None
ANSWER: B
Suppose a complete binary tree has height h>0. The minimum no of leaf nodes possible in term of
h is?
a) 2h -1
b) 2h -1 + 1
c) 2h -1
d) 2h +1
ANSWER: C
If a node having two children is to be deleted from binary search tree, it is replaced by its
a) In-order predecessor
b) In-order successor
c) Pre-order predecessor
d) None
ANSWER: B
A binary search tree is formed from the sequence 6, 9, 1, 2, 7, 14, 12, 3, 8, 18. The minimum number
of nodes required to be added in to this tree to form an extended binary tree is?
a) 3
b) 6
c) 8
d) 11
ANSWER: D
In a full binary tree, every internal node has exactly two children. A full binary tree with 2n+1
nodes contains
a) n leaf node
b) n internal nodes
c) n-1 leaf nodes
d) n-1 internal nodes
ANSWER: B
The run time for traversing all the nodes of a binary search tree with n nodes and printing them in
an order is
a) O(nlg(n))
b) O(n)
c) O(√n)
d) O(log(n))
ANSWER: B
When a binary tree is converted in to an extended binary tree, all the nodes of a binary tree in the
external node becomes
a) Internal nodes
b) External nodes
c) Root nodes
d) None
ANSWER: A
If n numbers are to be sorted in ascending order in O(nlogn) time, which of the following tree can
be used
a) Binary tree
b) Binary search tree
c) Max-heap
d) Min-heap
ANSWER: D
If n elements are sorted in a binary search tree. What would be the asymptotic complexity to
search a key in the tree?
a) O(1)
b) O(logn)
c) O(n)
d) O(nlogn)
View Answer / Hide Answer
ANSWER: C
If n elements are sorted in a balanced binary search tree. What would be the asymptotic
complexity to search a key in the tree?
a) O(1)
b) O(logn)
c) O(n)
d) O(nlogn)
ANSWER: B
Section – C (8 Mark)
Explain the various representations of binary tree in detail with suitable examples?
Explain in details about binary tree operations
Explain in detail about binary tree traversals
Explain Expression tree. How to convert expression trees into binary trees. Give example
What is binary search tree? Explain the insertion and deletion operations of binary search tree
with example
Define binary tree. Explain the insertion, deletion and searching operations of Binary tree with
algorithms
What is AVL tree? How to balanced the AVL tree?
Unit – III
Section – A (1 Mark)
A hash table of length 10 uses open addressing with hash function h(k)=k mod 10, and linear probing. After
inserting 6 values into an empty hash table, the table is as shown below. Which one of
the following choices gives a possible order in which the key values could have been inserted in the table?
A 46, 42, 34, 52, 23, 33
B 34, 42, 23, 52, 33, 46
C 46, 34, 42, 23, 52, 33
D 42, 46, 33, 23, 34, 52
Answer: C
How many different insertion sequences of the key values using the same hash function and linear probing
will result in the hash table shown above?
A 10
B 20
C 30
D 40
Answer C
The keys 12, 18, 13, 2, 3, 23, 5 and 15 are inserted into an initially empty 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?
AA
BB
CC
DD
Answer C
Consider a hash table of size seven, with starting index zero, and a hash function (3x + 4)mod7. Assuming
the hash table is initially empty, which of the following is the contents of the table when the sequence 1, 3,
8, 10 is inserted into the table using closed hashing? Note that ‘_’ denotes an empty location in the table.
A 8, _, _, _, _, _, 10
B 1, 8, 10, _, _, _, 3
C 1, _, _, _, _, _,3
D 1, 10, 8, _, _, _, 3
Answer B
Given the following input (4322, 1334, 1471, 9679, 1989, 6171, 6173, 4199) and the hash function x mod
10, which of the following statements are true? i. 9679, 1989, 4199 hash to the same value ii. 1471, 6171 has
to the same value iii. All elements hash to the same value iv. Each element hashes to a different value
(GATE CS 2004)
A i only
B ii only
C i and ii only
D iii or iv
Answer:C
Consider a hash table with 100 slots. Collisions are resolved using chaining. Assuming simple uniform
hashing, what is the probability that the first 3 slots are unfilled after the first 3 insertions?
A (97 × 97 × 97)/1003
B (99 × 98 × 97)/1003
C (97 × 96 × 95)/1003
D (97 × 96 × 95)/(3! × 1003)
Answer: A
Which one of the following hash functions on integers will distribute keys most uniformly over 10 buckets
numbered 0 to 9 for i ranging from 0 to 2020?
A h(i) =i2 mod 10
B h(i) =i3 mod 10
C h(i) = (11 ∗ i2) mod 10
D h(i) = (12 ∗ i) mod 10
Answer B
Given a hash table T with 25 slots that stores 2000 elements, the load factor α for T is __________
A 80
B 0.0125
C 8000
D 1.25
Answer A
Which of the following statement(s) is TRUE?
1. A hash function takes a message of arbitrary length and generates a fixed length code.
2. A hash function takes a message of fixed length and generates a code of variable length.
3. A hash function may give the same hash value for distinct messages.
A I only
B II and III only
C I and III only
D II only
Answer: C
Consider a hash function that distributes keys uniformly. The hash table size is 20. After hashing of how
many keys will the probability that any new key hashed collides with an existing one exceed 0.5.
A5
B6
C7
D 10
Answer D
Section – B (5 Mark)
1. Draw the complete undirected graphs on one, two, three, four and five vertices. Prove that
the number of edges in an n vertex complete graph is n(n-1)/2.
2. Draw the complete undirected graphs on one, two, three, four and five vertices. Prove that
the number of edges in an n vertex complete graph is n(n-1)/2.
3. What are the different ways of representing a graph? Represent the following
graph using those ways.
4. What are the different ways of representing a graph? Represent the following
graph using those ways.
5. Write an algorithm which does depth first search through an 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?
6. Which are the two standard ways of traversing a graph? Explain them with an
example of each.
7. Explain Dijkstra’s algorithm for finding the shortest path in a given graph.
8. What do you understand by tree traversal? Write a procedure for traversing a
binary tree in preorder .
9. How memory is freed using Boundary tag method in the context of Dynamic
memory management?
Section – C (8 Mark)
1.Write short notes on the following:
(i) Threaded binary trees.
(ii) Graph traversal.
(iii) Conversion of forest into tree.
2.What do you understand by structured programming? Explain.
3.Write an algorithm to sort a given list using Quick sort method. Describe the behaviour of Quick
sort when input is already sorted.
4.Sort the following list using Heap Sort
5, 33, 40, 20, 50, 88, 60, 11, 77, 30, 45, 65.
5.Define graph, adjacency matrix, adjacency list, hash function, sparse matrix, reachability matrix.
6.Explain various graph traversal schemes and write their merits and demerits.
7.Which sorting algorithm is easily adaptable to singly linked lists? Explain your answer.
8.What do you mean by complexity of an algorithm? Explain the meaning of worst case analysis
and best case analysis with an example..
9.Write an algorithm to insert a node in the beginning of the linked list.
Unit – IV
Section – A (5 Mark)
1) The operation of processing each element in the list is known as ......
A. sorting
B. merging
C. inserting
D. traversal
4) Graph G is .............. if for any pair u, v of nodes in G there is a path from u to v or path from v to
u.
A. Leterally connected
B. Widely Connected
C. Unliterally connected
D. Literally connected
7) Trees are said .......... if they are similar and have same contents at corresponding nodes.
A. Duplicate
B. Carbon copy
C. Replica
D. Copies
9) Every node N in a binary tree T except the root has a unique parent called the ......... of N.
A. Antecedents
B. Predecessor
C. Forerunner
D. Precursor
14) A binary tree whose every node has either zero or two children is called .......
A. complete binary tree
B. binary search tree
C. extended binary tree
D. data structure
Answers:
1) D. traversal
2) D. Digraph
3) A. Threaded trees
4) C. Unliterally connected
5) B. Terminal nodes
6) A. free graph
7) D. Copies
8) D. All of the above
9) B. Predecessor
10) D. both b and c
11) A. Array with pointers
12) D. All of the above
13) C. Empty
14) C. extended binary tree
15) C. 3
16) D. Dn = log2n+1
17) D. External node
18) C. Root, Left sub-tree, Right sub-tree
19) C. Internal node
20) B. Leaf
Section – B (5 Marks)
1. Bubble sort algorithm is inefficient because it continues 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.
2. What are B-trees? Construct a B-Tree of order 3 for the following set of Input data: 69, 19, 43, 16,
25, 40, 132, 100, 145, 7, 15, 18.
3. Draw the 11 item hash table resulting from hashing the keys: 12, 44, 13, 88, 23, 94, 11, 39, 20, 16
and 5 using the hash function h(i) = (2i+5) mod 11.
4. What is the average number of comparisons in a sequential search?
5. 1 Sort the following list using Heap Sort technique, displaying each step. 20, 12, 25 6, 10, 15, 13
6. When will you sort an array of pointers to list elements, rather than sorting the elements
themselves?
7. The element being searched for is not found in an array of 100 elements. What is the average
number of comparisons needed in a sequential search to determine that the element is not there, if
the elements are completely unordered?
8. Show the result of inserting the keys.
F, S, Q, K, C, L, H, T, V, W, M, R, N , P, A, B, X, Y, D, Z, E in the order to an empty B-tree of
degree-3.
9. What do you mean by hash clash? Explain in detail any one method to resolve hash collisions.
10. Define Hashing. How do collisions happen during hashing? Explain the different techniques
resolving of collision.
Section – C (8 Marks)
2) which of the following technique is not using for solve a 0-1knapsack problem
(A) Greedy (B) Dynamic programming (C) branch and bound (D) all of the above
3)For the following program gives Big O analysis of the running time (in terms of n)
For (i=0; i<n; i++)
A[i] = +;
(A) O(n-1) (B) O(n) (C) O(n2) (D) O(log n)
4) For the following program gives Big O analysis of the running time (in terms of n)
For (i=0; i< n; i++)
For (j=i; j< n; j++)
For (k=j; k< n; k++)
S++;
(A) O(n-1) (B) O(n2) (C) O(n3) (D) O(log n)
5) For the following program gives Big O analysis of the running time (in terms of n)
For (i=0; i < n*n; i++)
A[i] = i;
(A) O(n-1) (B) O(n2) (C) O(n3) (D) O(log n)
8) n! =
(A) O( 2n) (B) ω(2n) (C) A and B (D) O(n100)
Answers
1D
2A
3B
4C
5B
6A
7D
8C
9B
10 C
11 A
12 B
13 A
14 B
15 C