0% found this document useful (0 votes)
296 views

MCQs On DS

This document contains multiple choice questions related to data structures. It covers topics like linked lists, stacks, queues, trees, graphs and sorting. The questions test knowledge of these data structures, their properties, operations, time complexities and applications.

Uploaded by

Varshini
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
296 views

MCQs On DS

This document contains multiple choice questions related to data structures. It covers topics like linked lists, stacks, queues, trees, graphs and sorting. The questions test knowledge of these data structures, their properties, operations, time complexities and applications.

Uploaded by

Varshini
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 13

Multiple Choice Questions for Data Structures

1. Minimum number of fields in each node of a doubly linked list is


____
(A) 2
(B) 3
(C) 4
(D) None of the above
Ans: B
3
2. A graph in which all vertices have equal degree is known as
____
(A) Complete graph
(B) Regular graph
(C) Multi graph
(D) Simple graph
Ans: A
Complete graph
3. A vertex of in-degree zero in a directed graph is called a/an
(A) Root vertex
(B) Isolated vertex
(C) Sink
(D) Articulation point
Ans: C
Sink
4. A graph is a tree if and only if graph is
(A) Directed graph
(B) Contains no cycles
(C) Planar
(D) Completely connected
Ans: B
Contains no cycles
5. The elements of a linked list are stored
(A) In a structure
(B) In an array
(C) Anywhere the computer has space for them
(D) In contiguous memory locations
Ans: C
Anywhere the computer has space for them
6. A parentheses checker program would be best implemented using
(A) List
(B) Queue
(C) Stack
(D) Any of the above
Ans: C
Stack
7. To perform level-order traversal on a binary tree, which of the
following data structure will be required?
(A) Hash table
(B) Queue
(C) Binary search tree
(D) Stack
Ans: B
Queue
8. Which of the following data structure is required to convert
arithmetic expression in infix to its equivalent postfix notation?
(A) Queue
(B) Linked list
(C) Binary search tree
(D) None of above
Ans: D
None of above
9. A binary tree in which all its levels except the last, have maximum
numbers of nodes, and all the nodes in the last level have only one
child it will be its left child. Name the tree.
(A) Threaded tree
(B) Complete binary tree
(C) M-way search tree
(D) Full binary tree
Ans: B
Complete binary tree
10. Which of following data structure is more appropriate for
implementing quick sort iteratively?
(A) Deque
(B) Queue
(C) Stack
(D) Priority queue
Ans: C
Stack
11. The number of edges in a complete graph of n vertices is
(A) n(n+1)/2
(B) n(n-1)/2
(C) n 2 /2
(D) n
Ans: B
n(n-1)/2
12. If two trees have same structure and but different node content,
then they are called ___
(A) Synonyms trees
(B) Joint trees
(C) Equivalent trees
(D) Similar trees
Ans: D
Similar trees
13. If two trees have same structure and node content, then they are
called ____
(A) Synonyms trees
(B) Joint trees
(C) Equivalent trees
(D) Similar trees
Ans: C
Equivalent trees
14. Finding the location of a given item in a collection of items is called ……
A. Discovering
B. Finding
C. Searching
D. Mining
Ans. C
searching
15. The time complexity of quicksort is ……..
A. O(n)
B. O(logn)
C. O(n2)
D. O(n
logn) Ans.
D
O(n logn)
16. Quick sort is also known as ……..
A. merge sort
B. tree sort
C. shell sort
D. partition and exchange sort
Ans. D
partition and exchange sort
17.sorting is good to use when alphabetizing a large list of names.
A. Merge
B. Heap
C. Radix
D. Bubble
Ans. C
Radix
18. The total number of comparisons in a bubble sort is ….
A. O(n logn)
B. O(2n)
C. O(n2)
D. O(n)
Ans. A
O(n logn)
19.form of access is used to add and remove nodes from a queue.
A. LIFO, Last In First Out
B. FIFO, First In First Out
C. Both a and b
D. None of
these Ans. B
FIFO, First In First Out
20. New nodes are added to the.............of the queue.
A. Front
B. Back
C. Middle
D. Both A and
B Ans. B
Back
21. The term push and pop is related to
A. Array
B. Lists
C. Stacks
D. Trees
Ans. C
Stacks
22. Which of the following is an application of stack?
A. finding factorial
B. tower of Hanoi
C. infix to postfix
D. all of the
above Ans. D
all of the above
23. The operation of processing each element in the list is known as ……
A. sorting
B. merging
C. inserting
D. traversal
Ans. D
traversal
24. The situation when in a linked list START=NULL is ….
A. Underflow
B. Overflow
C. Houseful
D. Saturated
Ans. A
Underflow
25. Which of the following are two-way lists?
A. Grounded header list
B. Circular header list
C. Linked list with header and trailer nodes
D. List traversed in two
directions Ans. D
List traversed in two directions
26. Which is the pointer associated with the availability list?
A. FIRST
B. AVAIL
C. TOP
D. REAR
Ans. B
AVAIL
27. Which of the following data structure can’t store the non-homogeneous
data elements?
A) Arrays
B) Records
C) Pointers
D) Stacks
Ans. A
Arrays
28. Which of the following is non-liner data structure?
A) Stacks
B) List
C) Strings
D) Trees
Ans. D
Trees
29. To represent hierarchical relationship between elements, which
data structure is suitable?
A) Dequeue
B) Priority
C) Tree
D) Graph
Ans. C
Tree
30. Identify the data structure which allows deletions at both ends of the list
but insertion at only one end.
A) Input restricted dequeue
B) Output restricted qequeue
C) Priority queues
D) Stack
Ans. A
Input restricted dequeue

Q1. Consider the following tree

If the post-order traversal gives ab-cd*+ then the label of the nodes 1, 2, 3,…..will be:
(a) +, -, *, a, b, c, d (b) a, -, b, +, c, *, d
(c) a, b, c, d, -, *, + (d) -, a, b, +, *, c, d

Solution: Option (a)


Q2. Consider the following tree
If this tree is used for sorting, then a new number 8 should be placed as:

(a) left child of the node labeled 30


(b) right child of the node labeled 5
(c) right child of the node labeled 30
(d) left child of the node labeled 10
Solution: Option (d)
Q3. How many of possible ordered trees with 3 nodes A, B, C will be formed ?
(a) 16 (b) 12
(c) 6 (d) 10

Solution: Option (b)


Explanation:
Tree maybe of depth 2 or 1. If depth is 2, we have 6 possible trees. This is because one of the 3 nodes A, B,
C may be the root and the next level may be one of the remaining 2 nodes.

If the depth is 1, the root maybe one of the 3 nodes A, B, C. Corresponding to a root, say A, 2 trees are
possible as this.

This gives us 6 more possibilities.

Q 4. A binary tree in which every non-leaf node has non-empty left and right subtrees is called a strictly
binary tree. Such a tree with 10 leaves.
(a) maximum 19 nodes
(b) has exactly 19 nodes
(c) has exactly 17 nodes
(d) cannot have more than 17 nodes
Solution: Option (b)
Explanation:
The configuration of 10 leaves can only be of the following way:
Any tree with n-leaves, for strict binary tree has (2n-1) nodes.

Q5. What is the depth of a Complete Binary Tree with ‘n’ nodes is (log is to the base 2) ?
(a) log (n+1) -1

(b) log (n)


(c) log (n-1) +1

(d) log (n) +1

Solution: Option (a)


Explanation:
Try with values n=3 and check.

Q6. The result of preorder traversal is same as


(a) depth-first order

(b) breadth-first search


(c) topological order

(d) linear order

Solution: Option (a)


Q7. Which of the following traversal approach lists the nodes of a binary search tree in ascending order?
(a) Post-order

(b) In-order

(c) Pre-order

(d) None of these

Solution: Option (b)


Q8. How many binary trees are with possible with 3 nodes ?
(a) 12 (b) 13
(c) 5 (d) 15

Solution: Option (c)


Explanation:
The answer will be catalan’s number = 2nCn
(n+1)

= 6C3 (3+1)

= 6C3 = 5

Q9. How many binary trees are possible with 4 nodes ?


(a) 12 (b) 13
(c) 14 (d) 15

Solution: Option (c)


Q10. If the prefix traverse order of a tree is: * + ab – cd is then find the equivalent postfix order of tree .
(a) ab + cd – * (b) ab cd + – *
(c) ab + cd * – (d) ab + – cd *

Solution: Option (a)


Explanation:

*+ab – cd

The evaluation of the prefix order is (a+b)*(c – d) The corresponding tree is

Post-fix order is ab+cd– *

Q11. If a binary tree has n leaf nodes. The no. of nodes of degree 2 in this tree is:
(a) log2n (b) n-1
(c) n (d) 2n

Solution: Option (b)


Check for small values of n.

Q12. The number of Binary Trees with 3 nodes which when traversed by post-order gives the sequence A,
B, C is
(a) 3 (b) 9

(c) 7 (d) 5

Solution: Option (d)


The possible configurations are as shown in following figure
Q13. A 3-ary tree is a tree in which every internal node has exactly 3 children. What will be total number of
leaf nodes in such a tree if there are 6 internal nodes.
(a) 10 (b) 23

(c) 17 (d) 13

Solution: Option (d)


Explanation:
The no. of leaf nodes for n-array tree is:

L= (n-1) I +1

where I= no. of internal nodes Therefore, n=3, I=6, L= 13

Q14. Which of the following need not be binary tree?


(a) Heap (b) B-Tree
(c) AVL- Tree (d) None of these

Solution: Option (b)


Q15. If maximum height of binary tree is n then how many number of nodes will be there ?
(a) 2n-1 (b) 2n-1-1
(c) 2n+1-1 (d) 2n+1

Solution: Option (c)


Explanation:
Check for small values for n, For n=2

We get Option (c) 22+1 – 1= 23-1 = 7

Q16. The Inorder and Preorder traversal of a binary tree is d b e a f c g and a b d e c f g respectively.
Which among the following is the correct Post Order Traversal Sequence for this tree ?
(a) d e b f g c a (b) e d b g f c a

(c) e d b f g c a (d) d e f g b c a

Solution: Option (a)


Explanation
Post Order Traversal Follow the rule Left, Right, Node

Q17. Modes of a binary search tree have the values —1, 2, 3, 4, 5, 6, 7 and 8. Which among the following
will be the preorder traversal sequence of this binary search tree ?
(a) 5 3 1 2 4 7 8 6 (b) 5 3 1 2 6 4 8 7

(c) 5 3 2 4 1 6 7 8 (d) 5 3 1 2 4 7 6 8

Solution: Option (d)


Explanation

As per Preorder traverse Node , Left Right.

You might also like