cs301 Quiz
cs301 Quiz
7/8 + 9
If one converts the above expression into postfix, what would be the resultant
expression?
a) 7 8 9 / +
b) 7 8 / + 9
c) / 7 8 + 9
d) 7 8 / 9 +
4. Which of the following operation returns but do not removes top value of the
stack?
a) Push
b) Pop
c) Top
d)First
5. 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.
a) -
b) +
c) /
d) *
7. For making binary search tree for strings we need, data type.
a) Char
b) Int
c) Float
d) Double
8. Local variables defined inside function body are automatically at the end
of function execution.
a) Created
b) Destroyed
c) Incremented
d) Decremented
12. The lifetime of a transient object cannot exceed that of the application.
a) True
b) False
c) In some cases
d) None of the given
13. To represent hierarchical relationship between elements, which data
structure is suitable?
a) Dequeue
b) Priority
c) Stack
d) Tree
17. In a tree, we link the nodes in such a way that it a linear structure.
a) Does not remain
b) Forms
c) Reverses
d) Remains
19. All the objects created using operator have to be explicitly destroyed
using delete operator.
a) New
b) Delete
c) Del
d) Create
20. In the calling function, after the execution of the function called, the
program continues its execution from the after the function call.
a) Previous line
b) Next line
c) Beginning
d) None of the above
21. Last node in circular linked list contains
a) At least one null pointer
b) No null pointer
c) Maximum two null pointers
d) None of the given
22. One should be careful about transient that are stored by reference in data
structures.
a) Objects
b) Stack
c) Function
d) Tree
23) Binary search tree violates the condition of AVL tree when any node has
balance equal to
a) 2 or -2
b) 1 or -1
c) 0
d) None of the options
25. A binary tree whose every node has either zero or two children is called
.
a) Complete binary tree
b) Binary search tree
c) Strictly binary tree
d) None of above
28. In which traversal method, the recursive calls can be used to traverse a
binary tree?
a) In preorder traversal only
b) In inorder traversal only
c) In postorder traversal only
d) All of the given options
29. If we use doubly linked list to implement list then there is an issue of
a) Next pointer of first node and pre pointer of last node are NULL
b) Next pointer of first node and next pointer of last node are NULL
c) Pre pointer of first node and next pointer of last node are NULL
d) Pre pointer of first node and pre pointer of last node are NULL
30. In case of insertion of left outer node in BST,
a) We apply single right rotation to make it AVL tree.
b) We apply single left rotation to make it AVL tree.
c) We first apply right rotation and then left rotation to make it AVL tree.
d) We first apply left rotation and then right rotation to make it AVL tree.
31. Whenever we call a function, the complier makes a stack, the top element
of the stack is of the function.
a) First argument
b) Return address
c) Last argument
d) None of the above
32. Suppose a stack class has been defined using template. Now, we want to
declare a Stack object of an int type. What will be the correct syntax?
a) <int>Stack stack;
b) Stack<int> stack;
c) Stack int stack;
d) Int Stack stack;
33) In node class one field is an integer data and other field will be
a) Pointer to class
b) Pointer to node
c) Pointer to integer
d) None of given options
34. If there are 100,0000 unique members (nodes) stored in a complete binary
tree, the tree will have levels.
a) 10
b) 20
c) 30
d) 40
35. ~BinarySearchTree() is a .
a) Constructor
b) Destructor
c) Switch case
d) Template method call
42. In level-order traversal for binary search tree, we visit the nodes at each
level before proceeding to the next level, in a order.
a) Right-to-left
b) Left-to-right
c) Top-to-bottom
d) Bottom-to-top
43. The balance of a node in a binary tree is defined as the height of its sub
tree minus height of its right sub tree.
a) Right
b) Left
c) Upper
d) Lower
44. Allocating and de-allocating memory for linked list nodes does take __
time than pre- allocated array.
a) Less
b) More
c) Equal
d) No
50. The ___ is a decrement operator in C++ that decreases the value of the
operand by .
a) One
b) Two
c) Three
d) Four
51. Which of the following statement is correct for the variable “current __“?
a) Current = current + 1
b) Current = current - 1
c) Current = current - 2
d) Current – 1 = current
59. There are cases for deleting a node from binary search tree.
a) 1
b) 2
c) 3
d) 4
61. Suppose we have been given the following data set for a queue: 3 7 5 2 4
What will be the resultant queue if we call a front() method?
a) 7 5 2 4
b) 3 7 5 2 4
c) 7 5 2 4 3
d) 5 2 4
62. 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.
a) 7 5 2 4
b) 3 7 5 2 4
c) 7 5 2 4 3
d) 5 2 4 3
63. Maximum time that an insertion operation can take in AVL tree is .
Here log stands for log to the base of 2.
a) Log (n)
b) 1.44 log (n)
c) 1.66 log (n)
d) Log (n+1)
65. Left, right, info, and parent are the operations of data structure.
a) Stack
b) Tree
c) Queue
d) Linked list
69. Each node in a singly linked list contains two fields, one field called data
field while other field contains:
a) Pointer to an integer
b) Pointer to character
c) Pointer to next node
d) Pointer to class
75. What are the basic things associated with data structures?
a) Space for each data item it stores
b) Time to perform each basic operation
c) Programming effort
d) All of the above
76. In AVL tree insertion occurs on the inside in case and 3 which a single
rotation cannot fix.
a) 1
b) 2
c) 4
d) 5
79. Which data structure allows deleting data elements from front anf inserting
at rear?
a) Stacks
b) Queues
c) Deques
d) Binary search tree
81. A kind of expression where the operator is present between two operands
called expressions.
a) Infix
b) Postfix
c) Prefix
d) None of the above
84. ___ tree has been named after two persons Adelson-Velskii and Landis.
a) Binary
b) Black
c) AVL
d) VLA
87. A is a tree in which every level, except possibly the last, is completely
filled, and all nodes are as far left as possible.
a) Strict binary tree
b) Full binary tree
c) Perfect binary tree
d) Complete binary tree
88. A queue is a data structure where elements are
a) Inserted at the front and removed from the back
b) Inserted and removed from the top
c) Inserted at the back and removed from the front
d) Inserted and removed from both ends
89. Longest path from root node to farthest leaf node is called of tree.
a) Level
b) Length
c) Depth
d) Node level
93. An efficient program execute faster and helps in the usage of resources
like memory and disk
a) Maximizing
b) Minimizing
c) Equalizing
d) None of the given
98. If both left and right nodes of a node are NULL then this type of node is
called node.
a) Non leaf
b) internal
c) inner
d) leaf
99. Which of the following function don’t belongs to the stack class?
a) push()
b) pop()
c) crash()
d) top()
103. The of a node in a binary tree is defined as the height of its sub
tree minus height of its right sub tree.
a) Height
b) Balance
c) Width
d) None
111. While implementing stack with an array and to achieve LIFO behavior,
we used push and pop elements at .
a) The start of the array
b) The end of the array
c) The mid of the array
d) At least one position before array starting index.
114. The next field in the last node in a singly-linked list is set to .
a) 0
b) 1
c) NULL
d) False
115. Consider the linked list having data [6, 72, 35, 65,25] stored in it. While
current pointer is pointing memory location having 72 stored in it. After calling
remove() function on the following linked list current point will point to memory
location having value?
a) 6
b) 35
c) 65
d) 25
116. If we write functions for recursive and non recursive inorder traversal
method of BST, what will be the difference between its functions prototypes?
a) Different return types
b) Different function names
c) Different arguments list
d) Nothing will be different
117. In singly linked list a node comprises of field/s.
a) One
b) Two
c) Three
d) Four
129. Can we store elements with different data types in a single array?
a) Yes
b) No
c) In some cases
d) None of given
130. The lifetime of a transient object can exceed that of application which is
accessing it.
a) True
b) False
c) In some cases
d) None of the given
131. In a complete binary tree, for 25000 nodes the depth will be .
a) 13
b) 14
c) 15
d) 16
132. The smallest value element in a binary search tree(Each node with left
and right pointer) lies at
a) Root Node
b) Left Child of Root
c) Right Most Node
d) Left Most Node
133. If there are nodes in an avl tree its levels will be roughly as log2(10
million)
a) 100 million
b) 10 million
c) 5 million
d) 2 million
134. Which one is the correct function call for the following function of
calculatincube? int cube(int&num)
{
.
.
.
a) Cube(&num)
b) Cube(&&num)
c) Cube(*num)
d) Cube(num)
135. Which of the following is the correct option for priority Queue?
a) The type of Queue that is not FIFO i.e the person who comes first may not
leave first
b) The type of Queue that is not FIFO i.e the person who comes first
should leave first
c) The type of Queue that is not FIFO i.e the person who comes first should
leave first
d) The type of Queue that is not FIFO i.e the person who comes first may not
leave first
136. For String-based Binary Search Tree, We use ASCII values of characters
for comparing among letters. This method is known as
a) Lexicographic order
b) Alphabet coding procedure
c) Asymmetric technique
d) heap-based approach
137. Elements in a queue data structure are added from and remove from
.
a) Rear end. front end
b) Front end. Rear end
c) Front end
d) rear end
138. If numbers 5,222,4,48 are inserted in a queue. Which one will be remove
first?
a) 48
b) 4
c) 222
d) 5
140. During deletion of node from BST. if we found this node don't have in-
order successor and predecessor. it means this node is
a) Left Most node in the binary search tree
b) Right most node in the binary search tree
c) Root node
d) None of the given option
149. The of a binary tree is the maximum level of its leaves (also called the
depth).
a) Level
b) Width
c) Height
d) None of the above
150. Memory address is stored in
a) Address operator
b) Reference
c) Pointer
d) All of the given
151. A binary tree is said to be a binary tree if every non-leaf node fu tree
has non-empty left and right sub trees.
a) Complete
b) Strictly
c) AVL
d) Perfect
154. In AVL tree during insertion, a single rotation can fix the balance in cases
_________ and 4.
1
155. If a node is inserted in outer side of a node in binary search tree then to
make it AVL tree,
We may have to apply single rotation
164. In simple or singly linked list there is/are ________ pointer/s in each
node.
One
165. Suppose there are three nodes tree with three numbers 14, 4, 15.
Following is not a permutation, or combination for output them.
(4, 4, 15)
167. The _________ of a node in a binary tree is defined as the height of its
left subtree minus height of its right subtree.
Balance
168. If both left and right nodes of a node are NULL then this type of node is
called a ______ node.
Non leaf (not confirmed)
167. The function calls are made with the help of__________.
Stack
172. Which operation of queue data structure is used to get front element from
the queue and then remove it from the queue?
Remove ()
174. The _______ method of list will position the currentNode and
lastCurrentNode at the start of the list.
Start
175. Which operation of queue data structure is used to insert an element into
the Queue?
Enqueuer ()
176. From Operating System point of view, the recursive function calls are
made with the help of __________.
Queue
178. What are the basic things associated with data structures?
All of the above
185. Which of the following operation returns but do not removes top value of
the stack?
Top
191. The balance of a node in a binary tree is defined as the height of its
_______ sub tree minus height of its right sub tree.
Left
195. For making Binary Search Tree for Strings we need, ________ data
type.
Int
197. The lifetime of a transient object cannot exceed that of the application.
True
198. Which one of the following calling method does not change the original
value of the argument in the calling function?
Call by passing the value of the argument
199. In level-order traversal for Binary Search Tree, we visit the nodes at each
level before proceeding to the next level, in a _________ order.
Left-to-right
201. Binary Search Tree voilates the condition of AVL tree when any node
has balance equal to
1 or -1
202. To search an element in ALV tree, it takes maximum 1.88 Log 2n time
True
208. Which of the following function don't belongs to the stack class?
Crash ()
209. Which one is the cored function call for the following function of
calculating cube?
int cube(int& num)
cube (num)
215. While implementing stack with an array and to achieve LIFO behavior,
we used push and pop elements at
The start of the array
216. Generalized code written for a class is called
Structure
222. Want and de-allocating memory for linked lest nodes does take hrne than
pre-allocated array
MORE
223. Suppose you are writing a class for Node class and forgot to write the
constructor of the class, then
Compiler will automatically generate a default constructor
225. A binary tree is said to be a _____ binary tree if every non-leaf node in a
binary tree has non-empty left and right subtrees.
Strictly
231. The post order traversal of a binary tree is DEBFCA. Find out the pre
order traversal
A
Ʌ
B C
Ʌ ̸
DEF
ABDCEF
232. In a tree, we link the nodes in such a way that it ___________ a linear
structure.
Does not remain
239. Suppose you are writing a class for Node class and forgot to write the
constructor of the class, then _________ is the maximum height of the AVL
tree.
1.44log2n
242. Allocating and de-allocating memory for linked list nodes does take
_________ time than pre-allocated array.
More
244. In which case of insertion we require double rotation to make the AVL
tree balance.
None
247. Left, right, info, and parent are the operations of _________ data
structure.
Tree
248. Which of the following is TRUE for search operations in a binary tree as
compared to linked list or an array?
It increase the number of comparison
249. Which of the following is a correct statement?
An AVL tree is identical to BST except the height of left and right subtree
can differ by at least 1
251. Whenever we call a function, the compiler makes a stack, the top
element of the stack is _______ of the function.
Return Address
256. If we use array to implement list, then there is an issue that it gives
difficulty when:
We will access value randomly
258. Which one the following is more closer to AVL tree, (chose the best
option)
Binary Search Tree
266. What's wrong with following loop? while( (i < 10) && (i > 24)) { }
The Condition is always false
268. In which of the following tree for each node, the value of root node is
greater than left child and smaller than right child?
a) Binary search Tree
b) Full Binary Tree
c) Complete Binary Tree
d) Perfect Binary Tree
269. The first statement in the given code is called as:
a) Forward Declaration
b) Binary Declaration
c) Pre Class Declaration
d) Post Class Declaration
270. Convert the given infix from 12+60-23 of expression in postfix form.
a) 12 60 + -30
b) 12 60 + 23 –
d) +12 60 -23
271. The ___ sign before the name of the variable means that the address of
the variable is being
a) ||
b) #
c) ::
d) &
272. The first step to add a node in a linked list between the existing nodes is
a) newNode->getNext();
b) currenntNode->getNext();
c) newNode->setNext();
d) newNode->getNext(currentNode->getNext());
273. If we return the reference of a local variable from a function it will cause:
a) deletion of local variable from memory
b) duplication of local variable
c) reference overloading
d) dangling reference
274. After performing which task on the list, implementing array has to shift
the entire remaining elements one place to the left.
a) By adding element at last
b) By removing element at the end
c) By removing element at start
d) By searching of element
275. If a function has recursive call as the last statement, it is known as ___.
a) Local Recursion
b) Function recursion
c) Tail recursion
d) Last recursion
276. For searching a particular number in Binary Search Tree (if it is not
perfect), the maximum number of comparisons will be ___ comparison at
each level.
a) 4
b) 3
c) 2
d) 1
278. Level-order traversal for binary search tree can be implemented ___
a) Only through recursive method
b) Through max-heap
c) Only through non-recursive method
d) Through both recursive method call and non-recursive method call
280. The ___ of every node should be 1,0 or -1 otherwise, it will not be an
AVL tree.
a) size
b) width
c) length
d) balance
283. Which of the following is true for search operations in a binary tree as
cooperated to linked list or an array?
It reduces the number of comparisons
284. When a function, the parameters and return address of the calling
function are put in____________
Stack
287. in which of the following tree for each node, the value of root node is
greater than the left child and smaller than right child?
Binary search tree
289. The _ of every node has 1,0 or -1 otherwise, it will not be an AVL tree.
Balance
290. Which of the following operations returns the contents of a binary tree
node?
Info(p)
293. To create a ----------we link the last node with the first node in the list.
Circularly-linked list
295. If we want to return first element of the list which one method will be
used.
Get();
296. Convert the given infix form 12+60-23 of expression in postfix form.
12 60+23-
297. In which of the following function signatures, the value of variable “num”
cannot be changed in function body?
Int cube(const int&num)