0% found this document useful (0 votes)
143 views12 pages

Data Structure and Algorithm MCQ: A) B) C) D)

The document contains 59 multiple choice questions related to data structures and algorithms. The questions cover topics like linear data structures, trees, graphs, sorting algorithms, recursion, time complexity analysis and more. Sample questions ask about identifying the correct data structure used for a particular application (like stacks for converting infix to postfix notation), properties of different data structures (like the time complexity of quicksort), and evaluating postfix expressions.

Uploaded by

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

Data Structure and Algorithm MCQ: A) B) C) D)

The document contains 59 multiple choice questions related to data structures and algorithms. The questions cover topics like linear data structures, trees, graphs, sorting algorithms, recursion, time complexity analysis and more. Sample questions ask about identifying the correct data structure used for a particular application (like stacks for converting infix to postfix notation), properties of different data structures (like the time complexity of quicksort), and evaluating postfix expressions.

Uploaded by

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

Data Structure and Algorithm

MCQ
1 A linear list in which element can be added or removed at either end but not in
middle is known as
a) Stack
b) Circular Queue
c) De-Queue
d) Simple Queue
2 Which data structure is needed to convert infix notation to postfix notation?
a) Branch
b) Tree
c) Queue
d) Stack
3 The data structure required for Breadth First Traversal on a graph is?
a) Stack
b) Array
c) Queue
d) Tree
4 Binary trees can have how many children?
a) 2
b) any number of children
c) 0 or 1 or 2
d) 0 or 1
5 Time complexity of quick Sort in average case is
2
a) O (n )
b) O (n log n)
c) O (log n)
d) None of these
6 A vertex of degree zero is called
a) Isolated vertex
b) Pendant vertex
c) Colored vertex
d) Null vertex
7 Which data structure is used for implementing recursion?
a) Queue
b) Stack
c) Array
d) List
8 A BST is traversed in the following order recursively: Right, root, left. Theoutput
sequence will be in
a) Ascending order
b) Descending order
c) Bitomic sequence
d) No specific order
9 A binary tree is balanced if the difference between left and right sub-tree of every
node is not more than ____
a) 1
b) 3
Data Structure and Algorithm
MCQ
c) 2
d) 0
10 Which matrix has most of the elements (not all) as Zero?
a) Identity Matrix
b) Unit Matrix
c) Sparse Matrix
d) Zero Matrix
11 Which of the following traversal outputs the data in sorted order in a BST?
a) Preorder
b) Post order
c) Level order
d) In-order
12 Which data structure is used in redo-undo feature?
a) Stack
b) Queue
c) Tree
d) Graph
13 Stack is also called as
a) Last in first out
b) First in last out
c) Last in last out
d) First in first out

14 Any node is the path from the root to the node is called
a) Successor Node
b) Ancestor node
c) Internal node
d) None of the above
15 ………… is very useful in situation when data have to stored and then retrieved
in reverse order
a) Queue
b) Stack
c) Liked list
d) None of the these
16 Which of the following pairs of traversals is not sufficient to build a binary tree
from the given traversals?
a) Preorder and Inorder
b) Preorder and Postorder
c) Inorder and Postorder
d) None of the Above
17 The situation when in a linked list START=NULL is
a) Underflow
b) Overflow
c) Saturated
d) Houseful
18 Two main measures of the efficiency of an algorithm are
Data Structure and Algorithm
MCQ
a) Processor and memory
b) Complexity and capacity
c) Time and space
d) Data and space
19 Merge sort uses
a) Divide and conquer strategy
b) Backtracking approach
c) Heuristic search
d) Greedy approach
20 Which of the following data structure is linear type?
a) Graph
b) Tree
c) Binary search Tree
d) stack
21 If elements of the data structure forms a sequence of list then it is called as
____________
a) Linear data structure
b) Non-primitive data structure
c) Primitive data structure
d) None of these
22 Efficiency of an algorithm is measured by
a) Absolute analysis
b) Cost analysis
c) Relative analysis
d) Asymptotic analysis
23 ADT stands for:
a) Array data Type
b) Actual Data Type
c) Abstract Data Type
d) Assertion data type
24 Data structure that support efficient insertion of new records, is said to be
a) Array
b) Hash Table
c) Queue
d) stack
25 Heap is an example of
a) complete binary tree
b) spanning Tree
c) sparse tree
d) Binary search tree
26 In which data structure memory is contiguous
a) Array
b) Link list
c) Both
d) None
Data Structure and Algorithm
MCQ
27 A Binary Tree can have
a) Can have 2 children
b) Can have 1 children
c) Can have 0 children
d) All

28 Which expressions are also regarded as ' Reverse Polish Notations '?
a) Prefix
b) Postfix
c) Infix
d) All of the above
29 Which direction of scanning is suitable for the evaluation of a prefix expression?
a) Left to Left
b) Right to Right
c) Left to Right
d) Right to Left
30 Which of the following techniques represents the precise sequence of an In -
Order Traversal of a Binary Tree?
a) Visit the Root, Traverse Left Subtree, Traverse Right Subtree
b) Traverse Left Subtree, Visit the Root, Traverse Right Subtree
c) Traverse Left Subtree, Traverse Right Subtree, Visit the Root
d) None of the Above
31 What do the leaves of an expression tree represent?
a) Operand
b) Operator
c) Operation
d) All of the Above
32 What does a node possessing zero degree in Trees known as?
a) Branch Node
b) Root Node
c) Leaf Node
d) Trunk Node
33 Which type of linked list comprises the adjacently placed first and the last
elements?
a) Singly Linked List
b) Doubly Linked List
c) Circular Linked List
d) All of these

34 Traversal of a linked list always starts from the ________.


a) First Node
b) Middle Node
c) Last Node
d) None of the Above
35 How many pointers are necessarily changed for the insertion in a Linked List?
a) One
Data Structure and Algorithm
MCQ
b) Two
c) Three
d) Five
36 Which value of degree is specified / defined for an Isolated Vertex?
a) Zero
b) One
c) Infinity
d) Unpredictable
37 From where the insertion starts with a B tree?
a) Root node
b) Any node
c) Could be Root node or Any node
d) Leaf node
38 What is the Complexity of Binary Search Algorithm?
a) O(n)
b) O(log n)
c) O(n2)
d) O(n log n)
39 Evaluate the postfix expression 3574-2^*+
a) 41
b) 45
c) 48
d) None of the above
40 There are different ways of traversing a binary tree. What are those traversing
technique?
a) Prefix, infix, postfix
b) Pre-order, in-order, post-order
c) Pre-traversal, in-traversal, post-traversal
d) None of the above.
41 If you traverse a tree in the Inorder and find sorted listing of elements then it is a
a) Binary search tree
b) Binary tree
c) Heap
d) None of the above.
42 Leaves of which of the following trees are at the same level?
a) Binary tree
b) B-tree
c) AVL-tree
d) Normal Tree
43 In which tree, for every node the height of its left subtree and right subtree differ
almost by one?
a) Binary search tree
b) AVL tree
c) Threaded Binary Tree
d) Complete Binary Tree
44 From the following which data structure is used to perform recursion?
Data Structure and Algorithm
MCQ
a) FIFO
b) Stack
c) Binary Trees
d) Query
45 In a Queue, if a user tries to remove an element from empty Queue it is called
_________.
a) Underflow
b) Empty collection
c) Overflow
d) Garbage Collection
46 Suppose we are sorting an array of eight integers using quicksort, and we have
just finished the first partitioning with the array looking like this:
2 5 1 7 9 12 11 10
Which statement is correct?
a) The pivot could be either the 7 or the 9.
b) The pivot could be the 7, but it is not the 9
c) The pivot is not the 7, but it could be the 9
d) Neither the 7 nor the 9 is the pivot.
47 The postfix form of A*B+C/D is?
a) *AB/CD+
b) AB*CD/+
c) A*BC+/D
d)ABCD+/*
48 The prefix form of A-B/ (C * D ⋀ E) is?
a) -/*⋀ACBDE
b) -ABCD*⋀DE
c) -A/B*C⋀DE
d) -A/BC*⋀DE
49 What is the value of the postfix expression 6 3 2 4 + – *:
a) Something between -5 and -15
b) Something between 5 and -5
c) Something between 5 and 15
d) Something between 15 and 100
50 The number of nodes in a complete binary tree of level 5 is
a) 63
b) 53
c) 31
d) 42
51 No of edges in a complete connected graph is
a) 2n+2
b) 2n - 2
c) n2 -2
d) n(n-1)/2
Data Structure and Algorithm
MCQ
52 Infix notation for the postfix expression AB+C*D/
a. (A+B)/D*C
b. (A+B)*C/D
c. B-C*D+A
d. None of these

53 Maximum no of nodes in a binary tree of depth 5 is


a) 31
b) 16
c) 32
d) 15
54 The initial configuration of a queue is a, b, c, d, (‘a’ is in the front end). To get the
configuration d, c, b, a, one needs a minimum of
a) 2 deletions and 3 additions
b) 3 deletions and 2 additions
c) 3 deletions and 3 additions
d) 3 deletions and 4 additions
55 The result of evaluating the postfix expression 5, 4, 6, +, *, 4, 9, 3, /, +, * is?
a) 600
b) 350
c) 650
d) 588
56 Consider the following operation performed on a stack of size 5. Push(1); Pop();
Push(2); Push(3); Pop(); Push(4); Pop(); Pop(); Push(5);
After the completion of all operation, the number of elements present in stack are
a) 1
b) 2
c) 3
d) 4
57 A normal queue, if implemented using an array of size MAXgets full when
a) Rear = MAX – 1
b) Front = (rear + 1)mod MAX
c) Front = rear + 1
d) Rear = front
58 How many swaps are required to sort the given array using bubble sort - { 2, 5, 1,
3, 4}
a) 4
b) 5
c) 6
d) 7
59 The inorder and preorder traversal of a binary tree are DBACE and ABDCE
respectively. The postorder traversal of the binary tree is:
a) ABCDE
b) ECBDA
c) DBECA
d) BBECA
Data Structure and Algorithm
MCQ
60 What is the postfix form of the following prefix *+ab–cd
a) ab+cd–*
b) abc+*–
c) ab+*cd–
d) none of these
61 To represent hierarchical relationship between elements, Which data structure is
suitable?
a) Dequeue
b) Priority Queue
c) Tree
d) Graph
62 Which of the following sorting algorithm is of divide and conquer type?
a) Bubble Sort
b) Insertion sort
c) Quick Sort
d) Selection Sort
63 Time complexity of Bubble Sort
a) O(log n)
b) O(n)
c) O(n2)
d) O(n log n)
64 In Linked List there is no NULL link in:
a) Single Linked List
b) Circular Linked List
c) Doubly Linked List
d) None of these
65 The Postorder and and Inoder traversal of a tree are as follows:
Postorder: C D B E A
Inorder: C B D A E
What will be the Preorder tree?
a) A B C D E
b) B A D C E
c) A B D C E
d) A B D E C
66 Tight bound is denoted as___________
a) Ω
b) ϴ
c) O
d) o
67 How many swaps are required to sort the given array using bubble sort - { 3, 6, 2,
4, 5}
a) 4
b) 5
c) 6
d) 7
Data Structure and Algorithm
MCQ
68 What is the postfix form of the following prefix *+ab–cd
a) ab+cd–*
b) abc+*–
c) ab+*cd–
d) none of these
69 In a max-heap, element with the greatest key is always in the which node?
a) Leaf node
b) First node of left sub tree
c) root node
d) First node of right sub tree
70

If we implement heap as min-heap, deleting root node (value 1) from the heap.
What would be the value of root node after second iteration if leaf node (value
100) is chosen to replace the root at start?
a) 100
b) 2
c) 17
d) 3
71 In simple uniform hashing, what is the search complexity?
a) O(n)
b) O(logn)
c) O(nlogn)
d) O(1)
72 What is the hash function used in the division method?
a) h(k) = k/m
b) h(k) = k mod m
c) h(k) = m/k
d) h(k) = m mod k
73 Using division method, in a given hash table of size 15, the key of value 162 be
placed at position ____
a) 22
b) 2
c) 15
d) 12
74 What is the maximum possible number of edges in a directed graph with no self
loops having 8 vertices?
a) 28
b) 64
c) 256
Data Structure and Algorithm
MCQ
d) 56

75 What would be the DFS traversal of the given Graph?

a) ABCED
b) AEDCB
c) EDCBA
d) ADECB
76 In an 2D array A[25,4] with each element occupying 4 bytes of memory with the
address of the first element [1,1] is 2000. Find the address of [12,3].
a) 2444
b) 2184
c) 3244
d) 2180
77 For the tree below, write the post-order traversal

a) 4, 5, 2, 6, 7, 3, 1
b) 2, 3, 4, 5, 6, 7, 1
c) 4, 5, 6, 7, 2, 3, 1
d) 1, 2, 3, 4, 5, 6, 7
78 The optimal data structure used to solve Tower of Hanoi is _________
a) Tree
b) Heap
c) Priority queue
d) Stack
79 What would be the Prefix notation for the given equation?
A+B*C^D
a) +A*B^CD
b) +A^B*CD
c) *A+B^CD
Data Structure and Algorithm
MCQ
d) ^A*B+CD

80 The complexity of liniar search algorithm is:


a) O(n)
b) O(n2)
c) O(log n)
d) None of these
81 A binary tree whose every node has either 0 or 2 children are called
a) Extended Binary Tree
b) Binary Search Tree
c) AVL tree
d) Threaded Binary Tree
82 If a node having two children is deleted from a binary search tree, it is replaced by
its
a) Inorder Successor
b) Preorder Predecessor
c) Inorder Predecessor
d) Postorder Successor
83 Postorder traversal of a given binary search tree, T produces the following
sequence of keys
10, 9, 23, 22, 27, 25, 15, 50, 95, 60, 40, 29
Which one of the following sequences of keys can be the result of an in-order
traversal of the tree T?
a) 9, 10, 15, 22, 40, 50, 60, 95, 23, 25, 27, 29
b) 9, 10, 15, 22, 23, 25, 27, 29, 40, 50, 60, 95
c) 29, 15, 9, 10, 25, 22, 23, 27, 40, 60, 50, 95
d) 95, 50, 60, 40, 27, 23, 22, 25, 10, 9, 15, 29
84 Consider a node X in a Binary Tree. Given that X has two children, let Y be
Inorder successor of X. Which of the following is true about Y?
a) Y has no right child
b) Y has no left child
c) Y has both children
d) None of the above
85 8. Inserting an item into the stack when stack is not full is called …………. Operation
and deletion of item form the stack, when stack is not empty is called
………..operation.
a) push, pop
b) pop, pus
c) insert, delete
d) delete, insert
86 From where does the insertion and deletion of elements get accomplished in
Queues?
a) Front & Rear ends respectively
Data Structure and Algorithm
MCQ
b) Rear & Front ends respectively
c) Only Front ends
d) Only Rear ends
87 What should be the value of front if the queue is empty?
a. 1
b. (front= – 1) and (front>rear)
c. MAX + 1
d. MAX - 1
e. zero (null)
88 Which among the below specified condition is applicable if the Queue is non -
empty?
a) rear > front
b) rear < front
c) rear = front
d) Unpredictable
89 Which data structures find their applications in BFS and DFS Traversal
mechanisms on a Tree respectively?
a) Graph & Stack
b) Queue & Stack
c) Queue & Graph
d) None of the Above

90 How many elements are present in the stack if the variable top exhibits pointing
towards the topmost element in the Array?
a) top +1
b) top – 1
c) zero
d) infinite

You might also like