Cs301 Midterm Solved Mcqs by Junaid
Cs301 Midterm Solved Mcqs by Junaid
(SOLVED MCQs)
FROM MIDTERM PAPERS
LECTURE (1-22)
[email protected]
[email protected]
For More Visit: vulmshelp.com JUNAID MALIK
(0304-1659294)
AL-JUNAID TECH INSTITUTE
1. Consider the following infix
expression. 7/8+9
If one converts the above expression into postfix, what would be the
resultant expression?
a. 789/+
b. 78/+9
c. /78+9
d. 78/9+
2. Suppose there are 100 elements in an equivalence classes so initially
there will be 100 tree.The collection of tree is called_
a. Cluster
b. Class
c. Forest
d. Bunch
3. For a perfect binary tree of height h, having N nodes the sum of height
of nodes is
a. N-h-1
b. N-1
c. N-1+h
d. -(h-1)
4. Sorting procedure normally takes ______time
a. N log N
b. 2 N
c. N*N*N
d. N
5. there are 100 elements in an equivalence classes then will have
______state initially
a. 50
b. 100
c. 1000
d. 80
6. ________ objects (objects accessed by pointers) are called anonymous
objects.
a. Private
b. Nameless
c. Friend
AL-JUNAID TECH INSTITUTE
d. Public
7. ___________ is a self-balancing tree.
a. AVL
b. Binary Tree
c. Binary Search Tree
d. ALV
8. Which of the following operation returns but do not removes top value
of the stack?
a. Push
b. Pop
c. Top
d. First
9. 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. *
10. Which operation of the queue data structure is used to insert an
element into the Queue?
a. Enqueue()
b. Dequeue()
c. Fornt()
d. Remove()
11. For making binary search tree for strings we need, ________ data
type.
a. Char
b. Int
c. Float
d. Double
12. Local variables defined inside function body are ________
automatically at the end of function execution.
a. Created
b. Destroyed
c. Incremented
AL-JUNAID TECH INSTITUTE
d. Decremented
9. If a node has three fields, then this node will be related to
a. Linked list
b. Doubly linked list
c. Circular linked list
d. All of the given
10. ________ is an area in computer memory that is allocated
dynamically.
a. Heap
b. Stack
c. Queue
d. Linked list
11. Linked list use _______ to store data.
a. Array
b. 2-D Array
c. Variables
d. Linked Memory
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
14. Local variables of a function are stored in,
a. Binary search tree
b. Stack
c. Queue
d. AVL tree
15. In-order traversal method traverses tha data in
a. Non sorted order
b. Random order
AL-JUNAID TECH INSTITUTE
c. Sorted order
d. None of the given
16. Dequeue() operation of queue data structure is used to
_________
a. Get an element from the front of the queue
b. Remove an element from the front and return it
c. Insert an element at the front
d. Insert an element at the back
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
18. Factorial is an example of ________ function.
a. Recursive
b. Non-recursive
c. Cube
d. Log
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
AL-JUNAID TECH INSTITUTE
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
24. Security of data is the main usage of AVL tree.
a. True
b. False
c. In some cases
d. None of the given
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
26. In internal memory organization of a process, there is some area
of memory for static data that holds _________ variables.
a. Static
b. Global
c. Not static neither global
d. Both static and global
27. Following is true in case of using recursive method calls.
a. The code becomes very long
b. There is no effect on length of code
c. The code becomes very short
d. Code becomes very easy to understand
28. In which traversal method, the recursive calls can be used to
traverse a binary tree?
a. In preorder traversal only
AL-JUNAID TECH INSTITUTE
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
AL-JUNAID TECH INSTITUTE
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
36. _______ is utilized at the time of memory allocation in dynamic
manner.
a. Stack
b. Queue
c. Heap
d. All of the given
37. How many cases of rotation are there in AVL tree?
a. 2
b. 4
c. 6
d. 8
38. A list is the collection of items of the __________
a. May be of same or may be of different type
b. Different type
c. Same type
d. None of the above
39. Int * i =
new int[10];
Above given
code will:
a. Create an integer having value 10
b. Allocate memory for 9 integers
c. Allocate memory for 10 integers
d. Create 10 pointers of integer type
40. The depth of a binary tree is
a. Total number of nodes in the tree
AL-JUNAID TECH INSTITUTE
b. Number of leaf nodes in the tree
c. Number of non-leaf nodes in the tree
d. Maximum level of a leaf
41. A ________ model attempts to model a real-world phenomenon
a. Physical
b. Logical
c. Simulation
d. Conceptual
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
45. Consider we have performed the following
operations on a stack of size 5. Push(10);
Push(20);
Push(30);
Pop();
Pop();
Pop();
Push(40);
Push(50);
AL-JUNAID TECH INSTITUTE
Pop();
After the completion of all operation, the top element in stack is
_______.
a. 10
b. 20
c. 40
d. 50
46. Each operator in a postfix expression refers to the previous
_______ operand(s).
a. One
b. Two
c. Three
d. Four
47. In doubly linked list a node consists of three parts:
a. 1 pointer and 2 objects
b. 2 pointers and 1 object
c. 3 objects
d. 3 pointers
48. For reference variables, ________ sign is used.
a. Ampersand
b. Asterisk
c. Sigma
d. Dollar
49. Which of the following data structure is linear type?
a. Stack
b. List
c. Queue
d. All of the above
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- -“?
AL-JUNAID TECH INSTITUTE
a.Current = current + 1
b.Current = current - 1
c.Current = current - 2
d.Current – 1 = current
52. When an executable program runs, it is loaded in the computer
memory and becomes a
_______.
a. Thread
b. .h file
c. Process
d. None of the above
53. start() method of list class is used to:
a. Moves the “current” pointer to very first element
b. Moves the “current” pointer to very last element
c. Moves the “current” pointer to one step after the first element of
the array
d. Moves the “current” pointer to one step before the first element
of the array
54. a * (b + c) – d is an example of _______ expression.
a. Infix
b. Prefix
c. Postfix
d. Alfix
55. In a program a reference variable, say x, can be declared as
a. int &x;
b. int *x;
c. int x;
d. none of the given options
56. We allocate memory dynamically by using ______ operator.
a. This
b. New
c. Increment
d. Decrement
57. Get(?) method of list class is used to:
a. Get element from the last position
b. Get element from the first position
AL-JUNAID TECH INSTITUTE
c. Get element from the middle position
d. Get element at the given position
58. STL is a _______ that is a part of the official standard of C++.
a. C program file
b. .h file
c. .cpp file
d. Library
59. There are ____ cases for deleting a node from binary search tree.
a. 1
b. 2
c. 3
d. 4
60. In a list, tail() method of current pointer ________
a. Returns the last element of the “current” pointer
b. Moves the “current” pointer to the very first element
c. Moves the “current” pointer to the very last element
d. Returns the first element of the “current” pointer
61. Suppose we have been given the following data set for a queue:
37524
What will be the resultant queue if we call a front() method?
a. 7524
b. 37524
c. 75243
d. 5 2 4
62. Suppose we have been given the following data set for a queue:
7524
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. 7524
b. 37524
c. 75243
d. 5243
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)
AL-JUNAID TECH INSTITUTE
b. 1.44 log (n)
c. 1.66 log (n)
d. Log (n+1)
64. _______ is when function is calling to itself.
a. Loop
b. Recursion
c. Iteration
d. Nested loop
65. Left, right, info, and parent are the operations of ________ data
structure.
a. Stack
b. Tree
c. Queue
d. Linked list
66. Following is a keyword of C++
a. Del
b. Delete
c. Remove
d. Eliminate
67. The expression DE+H* is called ______
a. Prefix expression
b. Infix expression
c. Postfix expression
d. Hybrid expression
68. A software solution is said to be efficient if it solves the problem
__________.
a. By using some extra resources
b. Within no time
155. For every Process execute the last part of the Memory is
for__________of the Program
a. Data
b. Code
c. Stack
d. Heap
156. While implement non recursive traversal for binary search tree
we need to implement________
a. Que
b. Stack
c. Min heap
d. Max Heap
157. Suppose we have the following values to be inserted in
constructing AVL tree,
20,23,25,10, 12,13
Tell when first rotation will take place.
a. After increasing Node 25
b. After increasing Node 23
c. After increasing Node 10
d. After increasing Node 12
AL-JUNAID TECH INSTITUTE
158. If a tree has a 50 Node then the total linked in the tree will be
a. 55
b. 51
c. 50
d. 49
159. The percolate down procedure will move the smaller value
___and Bigger value___
a. Left, right
b. Right, left
c. Down, up
d. Up, down
a) Heap is empty
b) Heap is full
AL-JUNAID TECH INSTITUTE
c) Heap is not empty
d) Not a valid expression
171. A solution is said to be efficient if it solves the problem within its
resource constraints i.e. hardware and time.
a) True
b) False
172. A queue where the dequeue operation does not depend upon
FIFO, is called:
a) enqueue
b) simple queue
c) stack
d) priority queue
173. In simple or singly linked list there is/are ________ pointer/s in
each node.
a) One
b) Two
c) Three
d) Four
174. Which one of the following statement is correct?
a) Array size is fixed once it is created
b) Link List size is fixed once it is created
c) Binary Search Tree size is fixed once it is created
d) AVL Tree size is fixed once it is created
175. Which of the is NOT true regarding the maze generation?
a) Randomly remove walls until the entrance and exit cells are in same
set.
b) Removing a wall is the same as doing a union operation
c) Remove a randomly chosen wall if the cells it separates are alreadly in
same set
d) Do not remove a randomly chosen wall if the cells it separates are
alreadly in same set.
176. If Ahmad is cousin of Ali and Ali is cousin of Asad then Ahmad
is also cousin of Asad. This statement has the following property
a) Reflexivity
b) Symmetry
c) Transitivity
d) All of the given
177. Stack and Queue can be implemented using ________.
AL-JUNAID TECH INSTITUTE
a) Singly Link List
b) Binary Tree
c) Binary Search Tree
d) AVL Tree
178. 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?
a) Arrays
b) Linked Lists
c) Binary Search Trees
d) Stack
179. Recursive call of a function use ________ data structure.
a) Linked List
b) Queue
c) Stack
d) Table
180. The ________ of a node in a binary tree is defined as the height
of its left subtree minus height of its right subtree.
a) Height
b) Balance
c) Width
d) None of the above
181. Which operation of queue data structure is used to get front
element from the queue and then remove it from the queue?
a) enqueue()
b) dequeue()
c) front()
d) remove()
182. Suppose we have been given the following data set for a Queue.
7524
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) 7 5 2 4
c) 7 5 2 4 3
d) 5 2 4 3
183. In C++, we place the class interface in ________ file.
a) .cpp
b) .cppp
AL-JUNAID TECH INSTITUTE
c) .h
d) .hh
184. The array in binary search is sub divided ________.
a) Once
b) Twice
c) N time
d) Untill a sublist is no more divisible
185. If unions are done by weight (size), the depth of any element is
never greater than
a) log 3n
b) log2 n
c) n log2 n
d) log n*n
186. ________ in AVL is logarithmic.
a) Updating
b) Searching
c) Deletion
d) Insertion
187. What is the depth of any tree if the union operation is performed
by height?
a) O(N)
b) O(N log N)
c) O(log N)
d) O(M log N)
188. Avl tree takes maximum ________ time to search an element.
a) 1.44 Log2n
b) Log2(n+n)
c) Log2(n+1)+1
d) 1.88 Log2n
189. Which of the following is correct about AVL Tree?
a) It is identical to BST except height of the left and right subtrees can
differ by at least 1.
b) It is identical to BST except height of the left and right subtrees must
differ by at least 1.
c) It is not identical to BST, it is totally different kind of tree.
d) It is identical to BST except height of the left and right subtrees can
differ by at most 1.
190. "new int[11]" will allocate memory for ________ integers.
AL-JUNAID TECH INSTITUTE
a) 10
b) 11
c) 12
d) 13
191. The ________ method of list data structure removes the element
residing at the current position
a) Add
b) Next
c) Remove
d) Find
192. While implementing non-recusive traversal for Binary
SearchTree, we need to implement ________ .
a) Queue
b) Stack
c) Min heap
d) Max heap
193. Doubly Linked List always has ________ NULL pointer/s in a
node.
a) One
b) Two
c) Three
d) Four
194. For a perfect binary tree of height h, having N nodes, the sum of
hights of nodes ia ________.
a) N-h-1
b) N-1
c) N-1+h
d) N - (h - 1)
195. If there are N elements in an array then the number of maximum
steps needed to find an element using Binary Search is ___________.
a) N
b) N2
c) Nlog2N
d) log2N
196. Here is a small function definition:
void f(int i, int &k)
{
i = 1;
AL-JUNAID TECH INSTITUTE
k = 2;
}
Suppose that a main program has two integer variables x and y, which are
given the value 0. Then the main program calls f(x,y); What are the values of
x and y after the function f finishes?
a) Both x and y are still 0.
b) x is now 1, but y is still 0.
c) x is still 0, but y is now 2.
d) x is now 1, and y is now 2.
197. The worst case of searching in binary search tree (BST) is:
a) When the data inserted in BST is sorted
b) When the height of left sub-tree is greater than right sub-tree
c) When the height of right sub-tree is greater than left sub-tree
d) When the tree is balanced
198. What will be postfix expression of the following infix
expression?
Infix Expression: a+b*c-d
a) ab+c*d-
b) abc*+d-
c) abcd+*-
d) abc+*d-
199. What is the hash function used in linear probing?
a) hi(x)=hash(x) mod table size
b) hi(x)=(hash(x) + f(i^2)) mod table size
c) hi(x)= (hash(x)+ f(i)) mod table size
d) hi(x)= X mod 17
200. Each operator in a postfix expression refers to the previous
________ operand(s)
a) One
b) Two
c) Three
d) Four
201. In the statement int& a=b;
a) a and b pointing to two different memory location
b) a and b are two different names of the same memory location
c) a and b are two different variable names
d) b hold the address of variable a
202. In 1990, Bill pugh proposed an enhancement on linked lists and
the new data structure was termed as
AL-JUNAID TECH INSTITUTE
a) Linked list
b) B-Tree
c) Skip list
d) Spelling checker
203. Which of the following statement is NOT correct regarding Table
ADT?
a) In a table, the type of information in columns may be different.
b) A table consists of deveral columns known as entities
c) The row of a table is called a record
d) A major use of table is in databases where we build and use tables for
keeping information
204. A binary tree of N nodes has _____________ .
a) Log10 N levels
b) Log2 N levels
c) N / 2 levels
d) N x 2 levels
205. If the height of a perfect binary tree is 4. What will be the total
number of nodes in it?
a) 15
b) 16
c) 31
d) 32
206. Which property of equivalence relation is satisfied if we say:
Ahmad R(is related to) Ahmad
a) Reflexivity
b) Symmetry
c) Transitivity
d) All of the given
207. If ahmad is boss of ehsan and ehsan is boss of umer then ahmad
is also boss of umer. The above mentioned relation is ________.
a) Reflexive
b) Symmetry
c) Transitive
d) None of the given
208. Which of the following statement is false?
a) Arrays are dense lists and static data structure
b) data elements in linked list need not be stored in adjecent space in
memory
AL-JUNAID TECH INSTITUTE
c) pointers store the next data element of a list
d) linked lists are collection of the nodes that contain information part and
next pointer
209. Binary search algorithem cannot be applied to ________ .
a) Sorted linked list
b) sorted binary trees
c) sorted linear array
d) None of the given
210. Suppose there is an image segmented into pixels. Each pixel has
________ neighbour(s).
a) 0
b) 4
c) 8
d) 16
211. In singly linked list a node consists of two parts:
a) Object and structure
b) Two pointers
c) Two objects
d) Object and pointer
212. A hash function returns a ________ value.
a) Integer
b) Double
c) Float
d) Char
213. 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
214. The principal benefit of a link list over a conventional array is
that the order of the linked items may be____from the order that the
data seems are stored in memory.
a) Different
b) Identical
c) Same
d) Equivalent
215. The Computer memory can be thought of as a/an.
a) List
AL-JUNAID TECH INSTITUTE
b) Queue
c) Stack
d) Array
216. Before using the Pop method of a stack, the user must call
the__method.
a) isFull()
b) push()
c) pop()
d) isEmpty()
217. A stack carries____behavior.
a) FIFO
b) FEFO
c) LIFO
d) AVCO
218. ___Method returns the top element of the stack without removing
it.
a) Pop()
b) Front()
c) Push()
d) Top()
219. In Queue data structure element are removed from_____.
a) Pop
b) Push
c) Rear
d) Front
220. In Queue data structure element are full from_____.
a) Pop
b) Push
c) Rear
d) Front
221.
222. “end()” method of list performs its tasks in
a) Many Steps
b) Three Steps
c) One Steps
d) Two Steps
223. Linked List use____to store data.
a) Array
b) Variables
AL-JUNAID TECH INSTITUTE
c) Linked Memory
d) 2-D Array
224. Complete the push method code of stack void push (int x) {
A{____}=x}
a) Count++
b) Count—
c) ++count
d) –count
225. A template is a Function or Class that is Written a___data type.
a) Generic
b) None of These
c) Define
d) Specific
226. Trying to remove an element from an empty Stack is called____
a) Garbage Collection
b) Overflow stack
c) Empty collection
d) Underflow of Stack
227. Stack and Queue can be implemented using___
a) Binary Tree
b) Singly Linked List
c) AVL Tree
d) Binary Search Tree
228. A software solution is said to be efficient if it solves the problem.
a) With its resource constraints
b) With No Time
c) By Consuming more hardware resources.
d) By Using some extra resources.
229. we cannot remove items randomly from___
a) Stack
b) Queue
c) Stack and Queue
d) List
230. Stack push(15) will push 15 on___
a) Top of the Stack
b) Anywhere of the Stack
c) Middle of the Stack
d) Bottom of the Stack
AL-JUNAID TECH INSTITUTE
231. Which of the following is the correct conservation from infix to
postfix expression A*B+C/(E-F).
a) ABC*+EF-/
b) AB*CFE-/*
c) AB*C+EF/*
d) AB+C*E-F/
232. Convert the Given infix from 12+60-23 of expression in postfix
form.
a) 12+60 23-
b) 12 60+ -23
c) -12 60 -23
d) None
233. Y=&x[0];
In the above statement, we get the address of the Locatio of the array x
and store it in y. Here “Y” is;
a) Xvalue
b) Zvalue
c) Ivalue
d) Nvalue
234. Last Node in Circular Linked list Contains.
a) Maximum Two points
b) No Null Pointer
c) Atleast one Null pointer
d) None
235. 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 add(4) function on the following linked list current
point will point to memory location having value?
a) 36
b) 4
c) 72
d) 25
236. there is no such Node whose next filed is NULL which one of
the given option support the statement
a) Linked List
b) Circular Link list
c) Array
d) Queue