Multiple Choice Questions of Data Structure & Algorithm| Data Structure and algorithm MCQ

1. The logical or mathematical model of a particular organization of data is called

a.     Tree

b.    Algorithm

c.      Data structure

d.    File

2. The way in which the data items are logically related defines ————-

a.     Storage structure

b.    Data structure

c.      Data relationship

d.    Data operation

3. Which of the following is a linear data structure?

a.     Array   

b.    AVL trees

c.      Binary trees

d.    Graphs

4. Which of the following data structure is linear type?

a.     Graph

b.    Tree

c.      Binary tree

d.    Stack

5. Which data structure is not linear?

a.     Arrays

b.    Linked list

c.      Both

d.    None

6. Which of the following is not a linear data structure?

a.     Array

b.    Linked list

c.      Heap

d.    None of the above

7. The operation of processing each element in the list is known as :

a.     Sorting

b.    Merging

c.      Inserting

d.    Traversal

8. Finding the location of an element with a given value is :

a.     Traversal

b.    Search

c.      Sort

d.    Find

9. The operation of arranging data in a given order is known as

a.     Sorting

b.    Searching

c.      Traversing

d.    Hashing

10. Accessing each record exactly once so that certain items in the record may be processed is known as

a.     Traversing

b.    Searching

c.      Sorting

d.    Processing

11. Which of the following are the operations applicable on primitive data structure?

a.     Create

b.    Destroy

c.      Update

d.    All of the above

12. Which of the following data structure store the homogeneous data elements?

a.     Array

b.    Records

c.      Pointers

d.    List

13. In general, the index of the first element in an array is __________

a.     0

b.    -1

c.       2

d.     1

14. Linear array are also called

a.     Straight line array

b.    One-dimensional array

c.      Vertical array

d.    Horizontal array

15. Two dimensional arrays are also called

a.     Table arrays

b.    Matrix arrays

c.      Both

d.    none

16. Stack is

a.     LIFO

b.    FIFO

c.      FILO

d.    LILO

17. Which linear structure has a provision of Last-In-First-Out (LIFO) mechanism for its elements?

a.     Stack

b.    Queue

c.      Both (a) and (b)

d.    None of the above

18. Stack is called ___________

a.     Last in first out

b.    First in first out

c.      Last in last out

d.    None of the above

19. Stack has the property of ____________

a.     Last in first out

b.    First in first out

c.      Last in last out

d.    First in last out

20. Which of the following is known as LIFO?

a.     Array

b.    Linked list

c.      Queue

d.    Stack

21. Process of inserting an element in stack is called ____________

a.     Create

b.    Push

c.      Evaluation

d.    Pop

22. Process of removing an element from stack is called __________

a.     Create

b.    Push

c.      Evaluation

d.    Pop

23. Deleting an element from the stack is called

a.     Push operation

b.    Pop operation

c.      Del operation

d.    Rem operation

24. Which function places an element on the stack

a.     pop()

b.    push()

c.      peek()

d.    is empty()

25. What does ‘stack underflow’ refer to?

a.     Accessing item from an undefined stack

b.    Adding items to a full stack

c.      Removing items from an empty stack

d.    Index out of bounds exception

26. In a stack, if a user tries to remove an element from an empty stack it is called _________

a.     Underflow

b.    Empty collection

c.      Overflow

d.    Garbage Collection

27. Which data structure is mainly used for implementing the recursive algorithm?

a.     Queue

b.    Stack

c.      Array

d.    List

28. Which data structure do we use for testing a palindrome?

a.     Heap

b.    Tree

c.      Priority queue

d.    Stack

29. Which data structure is used for implementing recursion?

a.     Queue

b.    Stack

c.      Array

d.    List

30. Which term is used for Polish notation?

a.     Prefix

b.    Postfix

c.      Infix

d.    None of these

31. Reverse Polish notation is other name of

a.     Infix

b.    Prefix

c.      Postfix

d.    Algebraic expression

32. Which expression is also regarded as ‘Reverse Polish Notation’?

a.     Prefix

b.    Postfix

c.      Infix

d.    All of the above

33. The type of expression in which operator succeeds its operands is?

a.     Infix Expression

b.    Prefix Expression

c.      Postfix Expression

d.    Both Prefix and Postfix Expressions

34. 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

35. Which of the following data structures finds its use in recursion?

a.     Stack

b.    Arrays

c.      Linked List

d.    Queues

36. The data structure required to check whether an expression contains a balanced parenthesis is?

a.     Stack

b.    Queue

c.      Array

d.    Tree

37. Which of the following application of stack?

a.     Finding factorial

b.    Tower of Hanoi

c.      Infix to prefix

d.    All of the above

38. Which data structure can be used to check if a syntax has balanced parenthesis is?

a.     Queue

b.    Tree

c.      List

d.    Stack

39. Which of the following is not an inherent application of stack?

a.     Reversing a string

b.    Evaluation of postfix expression

c.      Implementation of recursion

d.    Job scheduling

40. Which data structure is needed to convert infix notation to postfix notation?

a.     Branch

b.    Tree

c.      Queue

d.    Stack

41. If TOP = MAX-1, then the stack is

a.     Empty

b.    Full

c.      Contains some data

d.    None of these

42. When does top value of the stack change?

a.     Before deletion

b.    While checking underflow

c.      At the time of deletion

d.    After deletion

43. 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

44. What will be the value of Top, if there is a size of stack STACK-Size is  5?

a.     5

b.    6

c.      4

d.    None of the above

45. How do the nested calls of the function get managed?

a.     Through queues

b.    Through stacks

c.      Through trees

d.    Through graphs

46. Pushing an element into stack already having five elements and stack size of 5, then stack becomes ___________

a.     Overflow

b.    Crash

c.      Underflow

d.    User flow

47. What does ‘stack overflow’ refer to?

a.     accessing item from an undefined stack

b.    adding items to a full stack

c.      removing items from an empty stack

d.    index out of bounds exception

48. When is the pop operation on stack considered to be an error?

a.     Only when the stack is empty

b.    Only when the stack is full

c.      When the stack is neither empty nor full

d.    Cannot be predicted

49. Which function plays an important role in returning the address of memory block allocated to locate/store a node especially while declaring ‘top’ in the linked representation of the stack?

a.     Galloc()

b.    Falloc()

c.      Malloc()

d.    Calloc()

50. Stacks do not find their applicability for

a.     Simplification of an arithmetic expression in postfix form

b.    Recursion implementation

c.      Conversion of infix to its equivalent postfix form

d.    Allocation of resources by an operating system

51. Which of the following data structures can be used for parentheses matching ?

a.     binary tree

b.    queue

c.      priority queue

d.     stack

52. Which of the following is not the application of stack?

a.     A parentheses balancing program

b.    Tracking of local variables at run time

c.      Compiler Syntax Analyzer

d.    Data Transfer between two asynchronous process

53. A queue is a

a.     FIFO (First In First Out)

b.    LIFO (Last In First Out)

c.      Ordered array

d.    Linear tree

54. Which data structure follows a FIFO system?

a.     Stack

b.    Queue

c.      Linked list

d.    Tree

55. In a queue, insertion is done at

a.     Rear

b.    Front

c.      Back

d.    Top

56. Which of the following data structure allows deleting data elements from and inserting at rear?

a.     Stack

b.    Queues

c.      Dequeues

d.    BST

57. From where does the insertion and deletion of elements get accomplished in Queues?

a.     Front and Rear ends respectively

b.    Rear and Front ends respectively

c.      Only Front ends

d.    Only Rear ends

58. A queue follows __________

a.     FIFO (First In First Out) principle

b.    LIFO (Last In First Out) principle

c.      Ordered array

d.    Linear tree

59. Which of the following properties is associated with a queue?

a.     First In Last Out

b.    First In First Out

c.      Last In First Out

d.    Last In Last Out

60. Which of the following is not the type of queue?

a.     Priority queue

b.    Single-ended queue

c.      Circular queue

d.    Ordinary queue

61. Which value is assigned/ set at front and rear ends during the initialization of a Queue?

a.     0

b.    1

c.      -1

d.    Infinity

62. In a queue, the initial values of front pointer ‘f’ rare pointer ‘r’ should be ________ and ________

a.     0 and 1

b.    0 and -1

c.      -1 and 0

d.    1 and 0

63. What should be the value of rear (end) if the queue is full (elements are completely occupied) ?

a.     1

b.    -1

c.      MAX +1

d.    MAX-1

64. Which of the following data structures allow insertion and deletion from both ends?

a.     Stack

b.    Dequeue

c.      Queue

d.    Strings

65. The function that deletes value from a queue is called

a.     Enqueue

b.    Dequeue

c.      Pop

d.    Peek

66. 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.     Queue

b.    Stack

c.      Tree

d.    Linked list

67. A data structure where elements can be added or removed at either end but not in the middle is called ________

a.     Linked list

b.    Stack

c.      queue

d.    Dequeue

68. Which linear list allows elements to be added or removed at either end but not in the middle?

a.     Queue

b.    Stack

c.      Dequeue

d.    Linked list

69. What is the term for inserting into a full queue known as ?

a.     Overflow

b.    Underflow

c.      null pointer exception

d.    program won’t be compiled

70. Circular Queue is also known as ________

a.     Ring Buffer

b.    Square Buffer

c.      Rectangle Buffer

d.    Curve Buffer

71.  A data structure in which elements can be inserted or deleted at/from both ends but not in the middle is?

a.     Queue

b.    Circular queue

c.      Dequeue

d.    Priority queue

72.  In a priority queue, if two elements have the same priority, then they are processed according to

a.     Their preference of the operating system

b.    Their position in the queue

c.      The order in which they were added to the queue

d.    The random selection by the system

73. ______ is not the operation that can be performed on queue.

a.     Insertion

b.    Deletion

c.      Retrival

d.    Traversal

74. What is the need for a circular queue ?

a.     Effective usage of memory

b.    Easier computations

c.      To delete elements based on priority

d.    Implement LIFO principle in queues

75. 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

76. What is the ‘next’ field of structure node in the Queue?

a.     Results into the storage of queue elements

b.    Results into the storage of address of next node by holding the next element of queue

c.      Results into the memory allocation of data elements to next node

d.    Results into the address allocation data elements to next node

77. Which among the below mentioned entities is/are essential for an array representation of a Queue?

a.     An array to hold queue elements

b.    A variable to hold the index of front element

c.      A variable to hold the index of rear element

d.    All of the above

78. A linked list is a

a.     Random access structure

b.    Sequential access structure

c.      Both

d.    None of these

79. 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.    Unordered list

80. An empty list is the one which has no ______________________

a.     Nodes

b.    Data

c.      Both (a) and (b)

d.    Address

81. Linked list is used to implement data structures like

a.     Stack

b.    Queues

c.      Trees

d.    All of these

82. Traversal of a linked list always starts from the

a.     First node

b.    Middle node

c.      Last node

d.    None of the above

83. Which term in linked list is used to refer to the situation where one wants to delete data from a data structure that is empty

a.     Overflow

b.    Underflow

c.      Null

d.    Error 

84. The pointer of the last node in a linked list contains a special value, called the

a.     Next node pointer

b.    Link field pointer

c.      Null pointer

d.    Node pointer 

85. In linked list each node contains a minimum of two fields. One field is data field to store the data, second field is?

a.     Pointer to character

b.    Pointer to integer

c.      Pointer to node

d.    Node

86. In Linked List implementation, a node carries information regarding ___________

a.     Data

b.    Link

c.      Data and Link

d.    Node

87. How many pointers are necessarily changed for the insertion in a linked list ?

a.     One

b.    Two

c.      Three

d.    Five

88. Doubly linked list is especially applicable, for which of the following implementation ?

a.     Double ended queue

b.    Linear list of integers

c.      Variable length String Data Structure

d.    All of the above

89. Which linked list does not store NULL in next field?

a.     Singly linked list

b.    Circular linked list

c.      Doubly linked list

d.    All of these

90. 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 the above

91. A linked list whose last node points back to the first node is called a/an

a.     Doubly linked list

b.    Double ended linked list

c.      Two way list

d.    Circular linked list

92. Which linked list stores the address of the header node in the next field of the last node?

a.     Singly linked list

b.    Circular linked list

c.      Doubly linked list

d.    Circular header linked list

93. Which linked list can have four pointers per node

a.     Circular doubly linked list

b.    Multi-linked list

c.      Header linked list

d.    Doubly linked list

94. The use of pointer to refer elements of data structure in which elements are logically adjacent is _________

a.     Pointers

b.    Linked allocation

c.      Stack

d.    Queue

95. Linked lists are not suitable for the implementation of

a.     Insertion sort

b.    Radix sort

c.      Polynomial manipulation

d.    Binary search

 96. Which is the most suitable construct utilized for traversing in a Circular linked list?

a.     Do-while

b.    While

c.      For

d.    If

97. Linked list is considered as an example of ___________ type of memory allocation.

 a.     Dynamic

b.    Static

c.      Compile time

d.    Heap

98. Linked list data structure offers considerable saving in _____________

a.     Computational Time

b.    Space Utilization

c.      Space Utilization and Computational Time

d.    Speed Utilization

99. To represent hierarchical relationship between elements, which data structure is suitable?

a.     Dequeue

b.    Priority queue

c.      Tree

d.    graph

100. The maximum number of nodes in a branch of a tree T is called its

a.     Level

b.    Label

c.      Deep

d.    Depth

101. The nodes in a tree with no successors are called

a.     Empty nodes

b.    Null nodes

c.      Terminal nodes

d.    Hash nodes

102. Degree of a leaf node is

a.     0

b.    1

c.      2

d.    3

103. The depth of a root node is

a.     0

b.    1

c.      2

d.    3

104. What does a node possessing zero degree in trees known as?

a.     Branch node

b.    Root node

c.      Leaf node

d.    Trunk node

105. 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

106. The number of edges from the node to the deepest leaf is called __________ of the tree.

a.     Height

b.    Depth

c.      Length

d.    MST

107. The number of edges from the root to the node is called _________ of the tree.

a.     Height

b.    Depth

c.      Length

d.    None of the above

108.  ____________ is a directed tree in which out degree of each node is less than or equal to two.

a.     Unary tree

b.    Binary tree

c.      Ternary tree

d.    Both (b) and (c)

109. The property of Binary tree————–

a.     The first subset is called left subtree

b.    The second subtree is called right subtree

c.      The root cannot contain NULL

d.    The right subtree can be empty

110. Binary trees can have how many children?

a.     2

b.    Any number of children

c.      0 or 1 or 2

d.    0 or 1

111. What is full binary tree?

a.     Each node has exactly zero or two children

b.    Each node has exactly two children

c.      All the leaves are at the same level

d.    Each node has exactly one or two children

112. Preorder traversal is also called

a.     Depth first

b.    Breadth first

c.      Level order

d.    In-order

113. What is the traversal strategy used in the binary tree?

a.     Depth-first traversal

b.    Breadth-first traversal

c.      Random traversal

d.    Preorder traversal

114. How to travel a tree in linked list representation?

a.    Using post order traversing

b.    Using preorder traversing

c.      Level order traversing

d.    All of the above

115. Visiting root node after visiting left and right sub-trees is called

a.     In-order Traversal

b.    Pre-order Traversal

c.      Post-order Traversal

d.    None of the above

116. Which of the following represents the Postorder Traversal of a Binary Tree?

a.     Left -> Right -> Root

b.    Left -> Root -> Right

c.      Right -> Left -> Root

d.    Right -> Root -> Left

117. A binary tree of height h has at least h nodes and at most  _________ nodes

a.     2h

b.    2h

c.      2 h+1

d.    2 h-1

118. The number of nodes at the nth level of a binary tree is

a.     2 n

b.    2n

c.      2 n+1

d.    2 n-1

119. The data structure required for Breadth First Traversal on a graph is?

a.     Stack

b.    Array

c.      Queue

d.    Tree

120. Which data structure is used in breadth first search of a graph to hold nodes?

a.     Stack

b.    Queue

c.      Tree

d.    Array

121. Which of the following ways can be used to represent a graph?

a.     Adjacency List and Adjacency Matrix

b.    Incidence Matrix

c.      Adjacency List, Adjacency Matrix as well as Incidence Matrix

d.    No way to represent

122. How many nested loops are present in Prim’s algorithm?

a.     Two

b.    Three

c.      Four

d.    Infinite

123. What is the value of the postfix expression 6 3 2 4 + – *?

a.     1

b.    40

c.      74

d.    -18

124. Which of the following is the postfix expression for the infix expression

(a+b) * (c-d)

a.     ab + cd – *

b.    abcd + – *

c.      ab * cd + –

d.    ab – cd + *

125. The postfix form of the expression (A+ B)*(C*D- E)*F / G is?

a.     AB+ CD*E – FG /**

b.    AB + CD* E – F **G /

c.      AB + CD* E – *F *G /

d.    AB + CDE * – * F *G /

126. The postfix form of A*B+C/D is?

a.     *AB/CD+

b.    AB*CD/+

c.      A*BC+/D

d.    ABCD+/*

127. The prefix form of A-B/ (C * D ^ E) is?

a.      -/*^ACBDE

b.     -ABCD*^DE

c.      -A/B*C^DE

d.    -A/BC*^DE

128. What is the result of the following operation?

Top (Push (S, X))

a.     X

b.    X+S

c.      S

d.    XS

129. The post fix equivalent of the prefix    * + ab – cd  is ——-

a.     ab + cd – *

b.    abcd + – *

c.      ab + cd * –

d.    ab + – cd *

130. The prefix form of an infix expression (p + q) – (r * t) is?

a.     + pq – *rt

b.    – +pqr * t

c.      – +pq * rt

d.    – + * pqrt

131. The result of evaluating the postfix expression 5, 4, 6, +, *, 4, 9, 3, /, +, * is?

 a.     600

b.    350

c.      650

d.    588

132. Convert the following infix expressions into its equivalent postfix expressions.

 (A + B D)/(E – F)+G

a.     (A B D + E F – / G +)

b.    (A B D + E F – / G +)

c.      (A B D + E F/- G +)

d.    (A B D E F + / – G +)

133. Convert the following Infix expression to Postfix form using a stack.
x + y * z + (p * q + r) * s, Follow usual precedence rule and assume that the expression is legal.

a.     xyz*+pq*r+s*+

b.    xyz*+pq*r+s+*

c.       xyz+*pq*r+s*+

d.    xyzp+**qr+s*+

134. Assume that the operators +,-, X are left associative and ^ is right associative. The order of precedence (from highest to lowest) is ^, X, +, -. The postfix expression for the infix expression a + b X c – d ^ e ^ f is?

 a.     abc X+ def ^^ –

b.    abc X+ de^f^ –

c.      ab+c Xd – e ^f^

d.    -+aXbc^ ^def

135. If the elements “A”, “B”, “C” and “D” are placed in a stack and are deleted one at a time, what is the order of removal?

a.     ABCD

b.    DCBA

c.      DCAB

d.    ABDC

136. 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.    ABDC

137. In Reverse Polish notation, expression A*B+C*D is written as

a.     AB*CD*+

b.    A*BCD*+

c.      AB*CD+*

d.    A*B*CD+ 

Algorithm:

137. The step by step procedure for calculation is called____________

a.      Program

b.    Algorithm

c.      Greedy method

d.     Problem

138. Which of the following is not a control structure used in algorithm?

a.     Sequence logic

b.    Selection logic

c.      Iteration logic

d.    Procedure logic

139. Two main measures for the efficiency of the algorithm are :

a.      Processor and memory

b.     Complexity and capacity

c.      Time and space

d.     Data and space

140. The amount of time needs to run to completion is known as __________

a.      Space complexity

b.     Worst case

c.      Best case

d.    Time complexity

141. The __________ of an algorithm is the amount of memory it needs to run to completion.

a.     Space complexity

b.     Time complexity

c.      Worst case

d.     Best case

142. Graphical representation of algorithm is  __________

a.     Flow chart

b.     Graph

c.      Pseudo-code

d.     Dynamic programming

143. Which from the following is not a criteria of algorithm

a.      Input

b.     Output

c.      Time complexity

d.    Best case

144. In algorithm comments begin with __________

a.      /*

b.     /

c.      */

d.    //

145. In algorithm specification the blocks are indicated with matching ______

a.     Braces

b.     Square brackets

c.      Parenthesis

d.     Slashes

146. Which of the following case does not exist in complexity theory?

a.      Best case

b.     Average case

c.      Worst case

d.    Null case

147. An algorithm that calls itself directly or indirectly is known as ______

a.      Sub algorithm

b.     Polish notation

c.      Recursion

d.     Traversal algorithm

148. The asymptotic notation for defining the average time complexity is :

a.     Equivalence

b.     Symmetric

c.      Reflexive

d.     Both b and c

149. What term is used to describe an O(n) algorithm?

a.      Constant

b.     Non-polynomial deterministic

c.      Logarithmic

d.    Linear

150. O(1) means computing time is ___________

a.     Constant

b.     Quadratic

c.      Linear

d.     Cubic

151. O(n2) means computing time is ___________

a.      Constant

b.    Quadratic

c.      Linear

d.     Cubic

152. O(2n)  means computing time is ____________

a.      Constant

b.    Exponential

c.      Quadratic

d.     Linear

153. Big ‘O’ gives

a.     Upper bound

b.    Lower bound

c.      Tight bound

d.    All of the above

154. Consider a situation where SWAP operation is very costly. Which of the following sorting algorithm should be preferred so that numbers of SWAP are minimized in general?

a.      Heapsort

b.     Insertion sort

c.      Selection sort

d.     Merge sort

155. The worst case series for insertion sort algorithm is

a.      O(n)

b.    O(n2)

c.      O(log n)

d.     O(n log n)

156.  In which sorting, consecutive adjacent pairs of element in the assay are compared with each other?

a.     Bubble sort

b.    Selection sort

c.      Merge sort

d.    Radix sort

157.  The complexity of Bubble sort is ___________

a.     O(n)

b.    O(log n)

c.      O(n2)

d.    O(n log n)

158. The average case occur in an algorithm of linear search :

a.     When item is somewhere in the middle of the array

b.     When item is not in the array at all

c.      When item is the last item in the array

d.     When the item is the last element in the array or it is not there at all

159. The complexity of a linear search algorithm is

a.      n+1/2

b.     n-1/2

c.      n/2

d.    n

160. The search algorithm which begins at a node A and then examines all the neighbors of node A is called

a.     Linear search

b.     Binary search

c.      Depth-first search

d.     Breadth-first search

161. The time complexity of binary search is _________

a.      O(1)

b.    O(log n)

c.      O(n)

d.     On(log n)

162. The complexity of binary search algorithm is _________

a.      O(n)

b.     O(n2)

c.      O(n log n)

d.    O(log n)

163. Which one of following is a condition that must be satisfied for binary search to work?

a.     The list must be short

b.    The list must be numeric

c.      The list must be sorted

d.    The list must have even number of elements

 

Leave a Comment