In the name of ALLAH, the most beneficient, the most merciful

Data Structures (CS301)

Multiple Choice Questions (MCQs)

Objective Questions

  1. Consider the following expression:
    x - y * a + b / c
    Which of the following is a correct equivalent expression for the above?

    1. x y -a * b +c /
    2. x *y a - b c / +
    3. x y a * - b c / +
    4. x y a * - b/ + c
  2. Non-recursive calls are faster than which of the following calls?

    1. Parameterized
    2. Recursive
    3. Function
    4. Non-Function
  3. The balance of a node is the result of "height of left subtree" ________ "height of right subtree".

    1. Plus
    2. Minus
    3. Multiply
    4. Divided by
  4. A complete binary tree having "N" nodes consists of ________ Levels.

    1. Log2 (N+1) -1
    2. Log2 (N-1) -1
    3. Log2 (N+1) +1
    4. Log2 (N-1) +1
  5. In the poat-order traversal of a binary search tree, nodes process as:

    1. Left-subtree, Right-subtree, Root
    2. Rightt-subtree, Root, Left-subtree
    3. Left-subtree, Root, Right-subtree
    4. Rightt-subtree, Left-subtree, Root
  6. The simplest case in a BST to delete a node is:

    1. When the node, that is to be deleted is root node
    2. When the node, that is to be deleted has both left and right child
    3. When the node, that is to be deleted has only one child
    4. When the node, that is to be deleted is a leaf node
  7. If class A defines class B as its friend, then:

    1. Class A can access private members of Class B
    2. Class B can access only the public members of Class A
    3. Class A can access only the public members of Class B
    4. Class B can access private members of Class A
  8. In the statement int& a=b;

    1. a and b pointing to two different memory location
    2. a and b are two different names of the same memory location
    3. a and b are two different variable names
    4. b hold the address of variable a
  9. The main use of AVL tree is:

    1. Searching of data
    2. Storing of data
    3. Insertion of data
    4. Security of data
  10. In simple implementation of stack, isFull() method is used due to ________.

    1. Limitation of array
    2. Strength of array
    3. Linked list connectivity
    4. Complexity of linked list
  11. Write in postfix form 5 * (9 - 7)

    1. 5 (9 7 -) *
    2. 5 9 * 7 -
    3. 5 9 7 - *
    4. 5 (9 7 -)
  12. What will be result of following postfix expression?

    1 2 3 * + 2 -

    1. 3
    2. 4
    3. 5
    4. 10
  13. An array x of 100 integers is declared as

    1. int x = [100];
    2. int x[100];
    3. integer array x = 100;
    4. integer x [] = 100;
  14. What is the maximum depth of recursive calls a function may make?

    1. 1
    2. 2
    3. n (where n is the argument)
    4. There is no fixed maximum
  15. A Linear Data Structure is the data structure in which data elements are arranged in a sequence or a linear list. Which of the following is Non Linear Data Structure?

    1. Arrays
    2. Linked Lists
    3. Binary Search Trees
    4. Stack
  16. The new operation in C++ for dynamically allocating memory returns,

    1. Size of the memory it has allocated
    2. Pointer to the memory it has allocated
    3. Both size and pointer to the memory it has allocated
    4. Value of the memory it has allocated
  17. In ________, a programmer uses two pointers in the node, i.e. one to point to next node and the other to point to the previous node.

    1. Linked list
    2. Doubly-linked list
    3. Array
    4. Structure
  18. The expression AB+C* is called?

    1. Prefix expression
    2. Postfix expression
    3. Infix expression
    4. Prefix and Infix expression
  19. Consider the function X as under
    int X (int& Value)
    {
    return Value;
    }
    Now a and b are integers in a calling function. Which one of the following is a valid call to the above function X?

    1. a = X(b);
    2. a = X(&b);
    3. a = X(*b);
    4. a = X(&*b);
  20. Each node in Binary Search Tree has

    1. 1 pointer
    2. 2 pointers
    3. 3 pointers
    4. 4 pointers
  21. Suppose n is the number of nodes in a complete Binary Tree, then maximum steps required for a search operation are

    1. Log2 (n+1) -1
    2. Log2 (n+1)
    3. Log2 (n) -1
    4. Log2 (n)
  22. The next field in the last node of a singly-linked list is set to ________.

    1. NAN
    2. 1
    3. 'NULL
    4. -1
  23. A queue where the dequeue operation does not depend upon FIFO, is called:

    1. enqueue
    2. simple queue
    3. stack
    4. priority queue
  24. a * (b+c)-d is an example of ________ expression.

    1. infix
    2. prefix
    3. postfix
    4. allfix
  25. Which one of the following calling methods does not change the original value of the argument in the calling function?

    1. Call by passing the value of the argument
    2. Call by passing reference of the argument
    3. Call by passing the address of the argument
    4. Call by passing pointer of the argument
  26. Which of the following statement is NOT true for reference variable?

    1. Once a reference is created, it cannot be later made to reference another object.
    2. Reference cannot be NULL
    3. References can be uninitialized.
    4. It is not possible to refer directly to a reference object after it is defined.
  27. Each operator in a postfix expression refers to the previous ________ operand(s).

    1. One
    2. Two
    3. Three
    4. Four
  28. Which one of the following statement is correct?

    1. Array size is fixed once it is created
    2. Link List size is fixed once it is created
    3. Binary Search Tree size is fixed once it is created
    4. AVL Tree size is fixed once it is created
  29. Linked list always contains elements that can be described as,

    1. Redundant
    2. Recursive
    3. Self-referential
    4. Bidirectional
  30. One difference between a queue and a stack is

    1. Queues require dynamic memory, but stacks do not.
    2. Stacks require dynamic memory, but queues do not.
    3. Queues use two ends of the structure, stacks use only one.
    4. Stacks use two ends of the structure, queues use only one.
  31. Stack and Queue can be implemented using ________.

    1. Singly Link List
    2. Binary Tree
    3. Binary Search Tree
    4. AVL Tree
  32. New items are added at the ________ of the stack.

    1. Bottom
    2. Middle
    3. Top
    4. Center
  33. ________ is the stack characteristic but ________ was implemented because of the size limitation of the array.

    1. isFull(), isEmpty()
    2. pop(), push()
    3. isEmpty(), isFull()
    4. push(), pop()
  34. The difference between a "Binary Tree (BT)" and a "Binary Search Tree (BST)" is that,

    1. A BST has two children per node whereas a BT can have none, one or two children per node
    2. In BST nodes are inserted based on the values they contain
    3. In BT nodes are inserted based on the values they contain
    4. There is no difference
  35. Which of the following operations returns "most recently entered value" from the stack?

    1. Push
    2. Recent
    3. Top
    4. First
  36. Which of the following is correct about AVL Tree?

    1. It is identical to BST except height of the left and right subtrees can differ by at least 1.
    2. It is identical to BST except height of the left and right subtrees must differ by at least 1.
    3. It is not identical to BST, it is totally different kind of tree.
    4. It is identical to BST except height of the left and right subtrees can differ by at most 1.
  37. In the call by ________ methodology, a copy of the object is passed to the called function.

    1. Reference
    2. Value
    3. Reference & Value
    4. Copy of the object can not be passed
  38. Recursive call of a function use ________ data structure.

    1. Linked List
    2. Queue
    3. Stack
    4. Table
  39. The variables which are destroyed automatically when a function's execution ends are:

    1. Global variables
    2. Local variables defined inside function body
    3. Variables (objects) defined inside function body dynamically
    4. Variables (objects) defined inside function body statically
  40. The worst case of searching in binary search tree (BST) is:

    1. When the data inserted in BST is sorted
    2. When the height of left sub-tree is greater than right sub-tree
    3. When the height of right sub-tree is greater than left sub-tree
    4. When the tree is balanced
  41. What will be the value of root of an AVL and BST if built from the same data?

    1. Same
    2. Different in some cases
    3. Root of AVL is square of root of BST
    4. None of the given
  42. What will be the postfix expression of following infix expression?
    A*B/C+D-E

    1. A B / C * D + E -
    2. A B * C / D + E -
    3. A B * C + D E / -
    4. A B + C D / + E -
  43. Leaf node of binary search tree contains ________.

    1. One Null pointer
    2. Three Null pointers
    3. Two Null pointers
    4. All of the given
  44. Each node in doubly link list has

    1. 1 pointer
    2. 2 pointers
    3. 3 pointers
    4. 4 pointers
  45. For reference variables, ________ sign is used.

    1. ampersand
    2. asterisk
    3. sigma
    4. dollar
  46. For searching a particular number in Binary Search Tree (if it is not present), the maximum number of comparisons will be ________ comparison at each level.

    1. 1
    2. 2
    3. 3
    4. 4
  47. Which of the following statement is false?

    1. Arrays are dense lists and static data structure
    2. data elements in linked list need not be stored in adjecent space in memory
    3. pointers store the next data element of a list
    4. linked lists are collection of the nodes that contain information part and next pointer
  48. The expression DE+H* is called ________.

    1. Prefix expression
    2. Infixexepression
    3. Postfix expression
    4. Hybrid expression
  49. An efficient program executes faster and helps in ________ the usage of resources like memory and disk.

    1. Maximizing
    2. Minimizing
    3. Equalizing
    4. None of the given
  50. Which operation of queue data structure is used to get front element from the queue and then remove it from the queue?

    1. enqueue()
    2. dequeue()
    3. front()
    4. remove()
  51. In singly linked list a node consists of two parts:

    1. Object and structure
    2. Two pointers
    3. Two objects
    4. Object and pointer
  52. The tree data structure is a

    1. Linear data structure
    2. Non-linear data structure
    3. Graphical data structure
    4. Data structure like queue
  53. For Binary Search Tree, we call the findMax() method as ________.

    1. findMin(tree->getLeft())
    2. findMin(tree->getRight())
    3. findMin(tree->getCenter())
    4. findMin(tree->getDown())
  54. In a tree, we link the nodes in such a way that it ________ a linear structure.

    1. does not remain
    2. forms
    3. reverses
    4. remains
  55. Doubly Linked List always has ________ NULL pointer/s in a node.

    1. One
    2. Two
    3. Three
    4. Four
  56. From Operating System point of view, the recursive function calls are made with the help of ________.

    1. Queue
    2. Stack
    3. Linked list
    4. Binary Search Tree
  57. The most difficult case for deleting a node from Binary Search Tree is when the node to be deleted ________.

    1. is Leaf node
    2. has only left children (subtree)
    3. has only right children (subtree)
    4. has both the left and right children (subtree)
  58. In simple or singly linked list there is/are ________ pointer/s in each node.

    1. One
    2. Two
    3. Three
    4. Four
  59. The tree structure is a

    1. Linear data structure
    2. Non-linear data structure
    3. Graphical data structure
    4. data structure like queue
  60. Consider we have performed the following operations on stack of size 5.
    Push(10);
    Push(20);
    Push(30);
    Pop();
    Pop();
    Push(40);

    1. 10
    2. 20
    3. 40
    4. 20
  61. Consider the following infix expression.
    7/8 + 9
    If one converts the above expression into postfix. What would be the resultant expression?

    1. 7 8 9 / +
    2. 7 8 / + 9
    3. / 7 8 + 9
    4. 7 8 / 9 +
  62. AVL tree is linear data structure.

    1. TRUE
    2. FALSE
    3. In some cases
    4. None of the given
  63. When we compare recursive method calls and non-recursive method calls, following statement is true.

    1. Recursion is implementted in the same way as other functioncalls are implemented
    2. Non-recursive methods are always efficient than recursive methods
    3. Both options are true
    4. None of the given options are true
  64. In C++, we place the class interface in ________ file.

    1. .cpp
    2. .cppp
    3. .h
    4. .hh
  65. ~BinarySearchTree() is a ________ .

    1. Constructor
    2. Destructor
    3. Switch case
    4. Template method call
  66. In level-order traversal for Binary Search Tree, at each level, we visit the nodes in ________ order.

    1. right-to-left
    2. left-to-right
    3. top to botton
    4. any
  67. next() method of List class is used to:

    1. Moves current position backward one element
    2. Moves the "current" pointer to two steps after the last elementof the array
    3. Moves the current position forward one element
    4. Moves the "current" pointer to two steps before the last element of the array
  68. Binary Search Tree voilates the condition of AVL tree when any node has balance equal to

    1. 2 or -2
    2. 1 or -1
    3. 0
    4. None of the options.
  69. In singly linked list which node will keep track of starting position of the list.

    1. Next Node
    2. Previous Node
    3. Head Node
    4. Last Node
  70. Local variables defined inside function body are ________ automatically at the end of function execution.

    1. created
    2. destroyed
    3. incremented
    4. decremented
  71. Can we store elements with different data types in a single array?

    1. Yes
    2. No
    3. In some cases
    4. None of the given
  72. Trying to remove an element from an empty stack is called ________ .

    1. Garbage collector
    2. Overflow of stack
    3. Empty collection
    4. Underflow of stack
  73. ________ is an area in computer memory that is allocated dynamically.

    1. Heap
    2. Stack
    3. Queue
    4. Linked List
  74. ________ is when function is calling to itself.

    1. Loop
    2. Recursion
    3. Iteration
    4. Nasted loop
  75. "new int[11]" will allocate memory for ________ integers.

    1. 10
    2. 11
    3. 12
    4. 13
  76. int htdiff = height(root->getLeft()) ________ height(root->getRight());
    The above line of code is taken from AVL insert method. Complete it by selecting an appropriate symbol.

    1. -
    2. +
    3. /
    4. *
  77. Longest path from root node to farthest leaf node is called ________ of tree.

    1. Level
    2. Length
    3. Depth
    4. Node level
  78. The depth of a binary tree is

    1. Total number of nodes in the tree
    2. Number of leaf nodes in the tree
    3. Number of non-leaf nodes in the tree
    4. Maximum level of a leaf
  79. Array cells are ________ in computer memory.

    1. Contiguous
    2. Random
    3. Store in multiple variables
    4. Store in multiple functions
  80. Which of the following operation returns but do not removes top value of the stack?

    1. push
    2. pop
    3. top
    4. first
  81. In case of insertion of right inner node in BST,

    1. we need to apply single left rotation to make it AVL tree.
    2. we need to apply single right rotation to make it AVL tree.
    3. single left rotation first and then single right rotation to make it AVL tree.
    4. single right rotation first and then single left rotation to make it AVL tree.
  82. get(?) method of list class is used to:

    1. Get element from the last position
    2. Get element from the first position
    3. Get element from the middle position
    4. Get element at the given position
  83. ________ is used for Reference variables in C++.

    1. !
    2. @
    3. #
    4. &
  84. Y = &x[0];
    In the above statement, we get address of the first location of the array x and store
    it in y. Here "y" is:

    1. rvalue
    2. xvalue
    3. lvalue
    4. zvalue
  85. Suppose we have been given the following data set for a Queue.
    7 5 2 4
    What will be the resultant Queue if we call enqueue(3) method?
    Note that 7 is the front element whereas 4 is rear element of queue.

    1. 7 5 2 4
    2. 3 7 5 2 4
    3. 7 5 2 4 3
    4. 5 2 4 3
  86. In tree, the search operation is ________ as compared to the linked list.

    1. Very fast
    2. not fast
    3. equally time-taken
    4. very slow
  87. To search an element in ALV tree, it takes maximum 1.88 Log2n time.

    1. TRUE
    2. FALSE
    3. In some cases
    4. None of the given
  88. ________ in AVL is logarithmic.

    1. Updating
    2. Searching
    3. Deletion
    4. Insertion
  89. The ________ of a node in a binary tree is defined as the height of its left subtree minus height of its right subtree.

    1. Height
    2. Balance
    3. Width
    4. None of the above
  90. Which of the following is not a form of exoression?

    1. Infix
    2. Postfix
    3. Prefix
    4. Pastfix
  91. What will be postfix expression of the following infix expression?
    Infix Expression: a+b*c-d

    1. ab+c*d-
    2. abc*+d-
    3. abcd+*-
    4. abc+*d-
  92. What will be the postfix expression of following infix expression?
    D+E*F/G

    1. DE*F/G+
    2. DE+F*G/
    3. DEF*G/+
    4. DE+FG*/
  93. Factorial is an example of ________ function.

    1. Recusive
    2. Non-Recursive
    3. Cube
    4. Log
  94. which of the following function don't belongs to the stack class?

    1. push()
    2. pop()
    3. crash()
    4. top()
  95. What will be the result of evaluation following expression?
    5+3*2/(6-3)

    1. 3
    2. 5
    3. 7
    4. 10
  96. Which of the following is correct statement?

    1. An AVL tree is identical to BST expect height of the left and right subtree can differ by at most 1.
    2. An AVL tree is identical to BST expect height of the left and right subtree can differ by at least 1.
    3. An AVL tree is identical to BST expect height of the left and right subtree must differ by at least 1.
    4. An AVL tree is not identical to BST, its another kind of tree.
  97. If we use array to implement list, then there is an issue that it gives difficulty when:

    1. We will access values randomly
    2. We will remove data from it
    3. We will increase its size
    4. We will decrease its size
  98. Which of the following can be used to reverse a string value?

    1. Stack
    2. Queue
    3. Both of these
    4. None of the given
  99. Binary search algorithem cannot be applied to ________ .

    1. sortrd linked list
    2. sorted binary trees
    3. sorted linear array
    4. None of the given
  100. Consider the linked list having data [6, 72, 35, 65, 25] stored in it. While current pointer is pointing to memory location having 72 stored in it. After calling add(4) function on the following linked list current point will point to memory location having value?

    1. 72
    2. 35
    3. 4
    4. 25
  101. for every process executing, the last part of the memory is for ________ of the program.

    1. Data
    2. Code
    3. Stack
    4. Heap
  102. Following is a keyword of C++ ________ .

    1. del
    2. delete
    3. Remove
    4. eliminate
  103. In doubly linked list there is/are _______ pointer/s in each node.

    1. One
    2. Two
    3. Three
    4. Four
  104. Avl tree takes maximum ________ time to search an element.

    1. 1.44 Log2n
    2. Log2(n+n)
    3. Log2(n+1)+1
    4. 1.88 Log2n
  105. There are four cases of rotation is an ________ tree.

    1. ELV
    2. EVL
    3. AVL
    4. ALV
  106. Allocating and de-allocating memory for linked list nodes take ________ time than pre-allocated array.

    1. Less
    2. More
    3. Equal
    4. No
  107. The binary tree is the maximum level of its leaves (also called the depth).

    1. Level
    2. Width
    3. Height
    4. None of the given
  108. If we singly linked list to implement list, then there is an issue that it gives difficulty when we:

    1. Move forward in the list
    2. Move backward in the list
    3. We will increase its size
    4. We will decrease its size
  109. back() method of list class is used to:

    1. Moves the "current" pointer to backward one element.
    2. Moves the "current" pointer to backward two element.
    3. Moves the "current" pointer to backward three element.
    4. Moves the "current" pointer to backward four element.
  110. While implementing non-recusive traversal for Binary SearchTree, we need to implement ________ .

    1. Queue
    2. Stack
    3. Min heap
    4. Max heap
  111. In which of the following function signatures, the value of variable "num" cannot be changed in function body?

    1. int cube(int num)
    2. int cube(int& num)
    3. int cube(const int& num)
    4. int cube(int* num)
  112. What are the basic things associated with data structures?

    1. Space for each data item it stores
    2. Time to perform each basic operation
    3. Programming effort
    4. All of the given
  113. Every AVL tree is a binary search tree.

    1. TRUE
    2. FALSE
    3. Not in some cases
    4. None of the given
  114. When an executable program runs, it is loaded in the computer memory and becomes a ________ .

    1. Thread
    2. .h file
    3. Process
    4. None of the given
  115. Left, right, info, and parent are the operation of ________ data structure.

    1. Stack
    2. Tree
    3. Queue
    4. Linked List
  116. Binary Tree traversal can be performed with the help of ________ .

    1. Recursive calls only
    2. Non-recursive calls
    3. Both Recursive and Non-recursive calls
    4. None of the given
  117. A solution is said to be efficient if it solves the problem within its resource constraints i.e. hardware and time.

    1. True
    2. False
  118. Each node in singly link list has,

    1. 1 pointer
    2. 2 pointers
    3. 3 pointers
    4. 4 pointers
  119. Parameters in function call are passed using,

    1. Stack
    2. Queue
    3. Binary Search Tree
    4. AVL Tree
  120. The ________ method of list data structure removes the element residing at the current position

    1. Add
    2. Next
    3. Remove
    4. Find
  121. Insertion in a linked list can be done at

    1. Front only
    2. Back only
    3. Somewhere in middle only
    4. Front, Back and somewhere in the middle
  122. An array is a group of ________ memory locations.

    1. Scattered
    2. Isolated
    3. Random (non-consecutive)
    4. Consecutive
  123. Which of the following applications may use a stack?

    1. Accessing a shadred resource
    2. Parentheses balancing program
    3. Buffering messages
    4. Waiting list
  124. Which one of the following is known as "Last-In, First-Out" or LIFO Data Structure?

    1. Linked List
    2. Stack
    3. Queue
    4. Tree
  125. Consider the following pseudo code
    declare a stack of characters
    while ( there are more characters in the word to read )
    {
    read a character
    push the character on the stack
    }
    while ( the stack is not empty )
    {
    pop a character off the stack
    write the character to the screen
    }

    What is written to the screen for the input "apples"?

    1. selpa
    2. selppa
    3. apples
    4. aaappppplleess
  126. What will be postfix expression of the following infix expression?
    Infix Expression: a+b*c-d

    1. ab+c*d-
    2. abc*+d-
    3. abc+*d-
    4. abcd+*-
  127. For compiler, a postfix expression is easier to evaluate than infix expression?

    1. True
    2. False
  128. _________ only removes items in reverse order as they were entered.

    1. Stack
    2. Queue
    3. Both of the given
    4. None of the given
  129. A binary tree of N nodes has _____________ .

    1. Log10 N levels
    2. Log2 N levels
    3. N / 2 levels
    4. N x 2 levels
  130. Consider the following function:
    void test_a(int n)
    {
    cout << n << " ";
    if (n>0)
    test_a(n-2);
    }

    What is printed by the call test_a(4)?

    1. 4 2 0
    2. 0 2 4
    3. 0 2
    4. 2 4
  131. The easiest case of deleting a node from BST is the case in which the node to be deleted _________.

    1. Is a leaf node
    2. Has left subtree only
    3. Has right subtree only
    4. Has both left and right subtree
  132. Every AVL is ___________.

    1. Binary Tree
    2. Complete Binary Tree
    3. Binary Search Tree
    4. None of the given
  133. Every AVL is ___________.

    1. Ternary Tree
    2. Complete Binary Tree
    3. Heap
    4. Binary Search Tree
  134. Searching an element in an AVL tree takes maximum _______ time (where n is number of nodes in AVL tree).

    1. Log2(n+1)
    2. Log2(n+1) -1
    3. 1.44 Log2n
    4. 1.66 Log2n