0% found this document useful (0 votes)
31 views68 pages

CS301 Midterm File

The document is a midterm preparation guide for CS301, authored by PIN2 and MUHAMMAD. It contains a series of multiple-choice questions covering various topics in computer science, such as data structures, algorithms, and memory management. The questions are designed to test knowledge on concepts like binary trees, stacks, queues, and recursion.

Uploaded by

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

CS301 Midterm File

The document is a midterm preparation guide for CS301, authored by PIN2 and MUHAMMAD. It contains a series of multiple-choice questions covering various topics in computer science, such as data structures, algorithms, and memory management. The questions are designed to test knowledge on concepts like binary trees, stacks, queues, and recursion.

Uploaded by

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

CS301 Midterm Preparation BY PIN2 And MUHAMMAD

(MAS All Rounder)

FOR MORE VU DATA VISIT MY website:


https://masallrounder.blogspot.com/

CS301 Midterm Preparation By


PIN2 and MUHAMMAD
(MAS All Rounder)
CS301 Midterm Preparation BY PIN2 And MUHAMMAD
(MAS All Rounder)
CS301 Midterm Preparation BY PIN2 And MUHAMMAD
(MAS All Rounder)

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. 2N
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.
CS301 Midterm Preparation BY PIN2 And MUHAMMAD
(MAS All Rounder)
a. Private
b. Nameless
c. Friend
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
CS301 Midterm Preparation BY PIN2 And MUHAMMAD
(MAS All Rounder)
12. Local variables defined inside function body are ________ automatically at the end of
function execution.
a. Created
b. Destroyed
c. Incremented
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


CS301 Midterm Preparation BY PIN2 And MUHAMMAD
(MAS All Rounder)
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

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
CS301 Midterm Preparation BY PIN2 And MUHAMMAD
(MAS All Rounder)

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


CS301 Midterm Preparation BY PIN2 And MUHAMMAD
(MAS All Rounder)
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


CS301 Midterm Preparation BY PIN2 And MUHAMMAD
(MAS All Rounder)

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

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
CS301 Midterm Preparation BY PIN2 And MUHAMMAD
(MAS All Rounder)

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


CS301 Midterm Preparation BY PIN2 And MUHAMMAD
(MAS All Rounder)
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

b. Number of leaf nodes in the tree


CS301 Midterm Preparation BY PIN2 And MUHAMMAD
(MAS All Rounder)

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
CS301 Midterm Preparation BY PIN2 And MUHAMMAD
(MAS All Rounder)

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);

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
CS301 Midterm Preparation BY PIN2 And MUHAMMAD
(MAS All Rounder)
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- -“?

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
CS301 Midterm Preparation BY PIN2 And MUHAMMAD
(MAS All Rounder)

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
CS301 Midterm Preparation BY PIN2 And MUHAMMAD
(MAS All Rounder)
57. Get(?) method of list class is used to:

a. Get element from the last position

b. Get element from the first position

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
CS301 Midterm Preparation BY PIN2 And MUHAMMAD
(MAS All Rounder)

c. 75243

d. 524

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)

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
CS301 Midterm Preparation BY PIN2 And MUHAMMAD
(MAS All Rounder)
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

c. By consuming more hardware resources

d. Within its resources constraints

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
70. Each node in singly linked list contains _______
CS301 Midterm Preparation BY PIN2 And MUHAMMAD
(MAS All Rounder)

a. One pointer

b. Two pointers

c. No pointer

d. NULL pointer

71. Every AVL tree is a binary search tree.

a. True

b. False

c. Not in some cases

d. None of the given

72. In singly linked list “next” field of node contains:

a. Address of next node

b. Object of next node

c. Object of current node

d. Address of head node

73. Two common models of simulation are _____ and _____.

a. Circuit-based simulation and Event- based simulation

b. Circuit-based simulation and Time-based simulation

c. Time-based simulation and Event- based simulation

d. None of the above

74. Stack and Queue can be implements using _____.

a. Singly Link List

b. Binary Tree

c. Binary search Tree


CS301 Midterm Preparation BY PIN2 And MUHAMMAD
(MAS All Rounder)

d. AVL Tree
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
77. add(12) method of linked list class will

a. Add 12 nodes in linked list

b. Add 12 pointers in linked list

c. Add 12 as value in linked list

d. Add 12 values in linked list


78. Which of the following is a non- linear data structure?

a. Stack

b. Queue

c. Tree

d. Linked list

79. Which data structure allows deleting data elements from front anf inserting at
rear?

a. Stacks
CS301 Midterm Preparation BY PIN2 And MUHAMMAD
(MAS All Rounder)

b. Queues

c. Deques

d. Binary search tree

80. Array cells are ____ in computer memory.

a. Contiguous

b. Random

c. Store in multiple Variables

d. Store in multiple functions


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

82. back() method of list class is used to

a. Moves the "current" pointer to backward one element.

b. Moves the "current" pointer to backward two element.

c. Moves the "current" pointer to backward three element.

d. Moves the "current" pointer to backward four element.

83. next() method of List class is used to:

a. Moves the Current position backward one element

b. Moves the "Current" pointer to two steps after the last element of the array

c. Moves the Current position forward one element

d. Moves the "Current" pointer to two steps before the last element
of the array
84. _________tree has been named after two persons Adelson Velskii and Landis.
CS301 Midterm Preparation BY PIN2 And MUHAMMAD
(MAS All Rounder)

a. Binary

b. Black

c. AVL

d. VLA

85. There are four cases of rotation in an _______ tree.

a. ELV

b. EVL

c. AVL

d. ALV

86. _______ is used for reference variable in C++.

a. !

b. @

c. #

d. &

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.
CS301 Midterm Preparation BY PIN2 And MUHAMMAD
(MAS All Rounder)

a. Level

b. Length

c. Depth

d. Node level

90. New items are added at the ______ of the stack.

a. Bottom

b. Middle

c. Center

d. Top
91. Length() method of list class is used to:

a. Return the length of the array

b. Return the length of the list

c. Return the length of empty part of the array

d. Return the length of empty part of the list

92. The function calls are made with the help of ________.

a. Stack

b. Heap

c. Dynamic memory

d. External memory
93. An efficient program execute faster and helps in _____ the usage of resources like
memory and disk

a. Maximizing

b. Minimizing
CS301 Midterm Preparation BY PIN2 And MUHAMMAD
(MAS All Rounder)

c. Equalizing

d. None of the given


94. Generalized code written for a class is called:

a. Function

b. Template

c. Structure

d. Stack
95. "set()" method of list class is used to:

a. Set the value of Pointer

b. Set the value of Null Nodes

c. Set the value of objects

d. Set the value of Value

96. In C++, we place the class interface in ___ file.

a. .cpp

b. .cppp

c. .h

d. .hh
97. Every _____ tree is a binary search tree.

a. AVL

b. binary

c. big

d. small
98. If both left and right nodes of a node are NULL then this type of node is called
____ node.

a. Non leaf
CS301 Midterm Preparation BY PIN2 And MUHAMMAD
(MAS All Rounder)

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()
100. For a complete binary tree, the depth is calculated as____ a. log2(number of
nodes+1)-1

b. log2(number of nodes*1)+1

c. log2(number of nodes-1)-1

d. log2(number of nodes-1)+1

101. ___ only removes items in reverse order as they were entered

a. Queue

b. Stack

c. Both of these

d. None of these
102. What will be the postfix expression of following infix
expression? D+E*F/G a. DE*F/G

b. DE+F*G/

c. DEF*/+

d. DE+FG*/

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
CS301 Midterm Preparation BY PIN2 And MUHAMMAD
(MAS All Rounder)

b. Balance

c. Width

d. None
104. The back() method decreases the value of Variable current
by____

a. Four

b. Three

c. Two

d. One

105. In doubly linked list there is/are_____pointer/s in each node.

a. One

b. Two

c. Three

d. Four

106. Suppose we have the following values to be inserted in


constructing AVL tree,
10, 13, 15, 5, 7, 8
Tell when first rotation will take place. a. After
inserting node 13

b. After inserting node 15

c. After inserting node 5

d. After inserting node 7


107. Binary search algorithm cannot be applied to ___ a. Sorted linked list

b. sorted binary trees

c. sorted linear array

d. None of given option


CS301 Midterm Preparation BY PIN2 And MUHAMMAD
(MAS All Rounder)
108. During the execution of a process operating system constructs focus things for that
process which of the following is
not part of that process

a. A section for static data including global variable

b. Stack

c. Heap

d. Linked list
109. Which one of the following method does not change the original value of the
argument in the calling function?

a. Call by passing reference of the argument

b. Call by passing the address of the argument

c. Call by passing the value of the argument

d. None of the given options


110. _____ is the major factor to see the efficiency of a program.

a. Quality

b. Time

c. Correctness

d. None of the given

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.

112. A template is a function or class that is written with a ________

a. Specific

b. Definite
CS301 Midterm Preparation BY PIN2 And MUHAMMAD
(MAS All Rounder)

c. Generic

d. None of the above

113. In the linked list implementation of the stack class, where does the push member
function places the new entry on the linked list?

a. After all other entries that are greater than the new entry

b. At the head

c. After all other entries that are smaller than the new entry

d. At the tail
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


CS301 Midterm Preparation BY PIN2 And MUHAMMAD
(MAS All Rounder)
117. In singly linked list a node comprises of _________ field/s.

a. One

b. Two

c. Three

d. Four

118. Doubly linked list always has ______ NULL pointers in a node.

a. One

b. Two

c. Three

d. Four

119. A BST generated from the data in ascending order is ________.

a. Linear

b. Nonlinear

c. Balanced

d. Un sorted
120. Linked list is generally considered an example of _______ type of memory location. a.
Static

b. Compile time

c. Dynamic

d. None of given options

121. What’s wrong with following loop?


while((i < 10) && (i > 24)){
}

a. The logical operator && cannot be used in a test condition

b. The while loop is an exit-condition loop


CS301 Midterm Preparation BY PIN2 And MUHAMMAD
(MAS All Rounder)
c. The test condition is always false
d. The test condition is always true
122. Making the tree unbalanced, it violates the ______ rule.

a. Linked list

b. Stack

c. AVL

d. Queue

123. copy() method of list data structure _________ a. copy first item of list

b. set one list to be a copy of another

c. copy last item of list

d. copy any item of list

124. Deleting a ______ node in BST is a ______ case. a. Root, simplest

b. Left child, simplest

c. Right child, simplest

d. Leaf, simplest

125. We can not remove items randomly from ________

a. Stack

b. Queue

c. Both of these

d. None of these
126. NULL is an invalid address and ________. a. Accessible

b. Inaccessible

c. Points to the start point of the list

d. Points to the last point of the list 127. A stack carries _______ behavior.

a. FIFO

b. LIFO
CS301 Midterm Preparation BY PIN2 And MUHAMMAD
(MAS All Rounder)

c. AVCO

d. FEFO

128. The tree data structure is a a. Linear data structure

b. Non-linear data structure

c. Graphical data structure

d. Data structure like queue


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 we use array to implement list, then there is an issue that is gives difficulty when
a. We will access values randomly

b. We will remove data from it


CS301 Midterm Preparation BY PIN2 And MUHAMMAD
(MAS All Rounder)
c. We will increase its size
d. We will decrease its size
134. 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
135. 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)

136. 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
137. 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
CS301 Midterm Preparation BY PIN2 And MUHAMMAD
(MAS All Rounder)
d. heap-based approach
138. 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
139. 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. A zigzag rotation is performed. In Left-Left case of rotation in
AVL tree. a. True

b. False

c. In some cases

d. None of the above

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


142. _____ rule applies for evaluating operators of same precedence in
an expression

a. right to left

b. Cascading

c. Associative

d. None of the above

143. What will be result of following postfix expression?


1 23*+2–

a. 3

b. 4
CS301 Midterm Preparation BY PIN2 And MUHAMMAD
(MAS All Rounder)

c. 5

d. 10

144. The main use of AVL tree is: a. Searching of data


b. Storing of data

c. Insertion of data

d. Security of data
145. y = &x[0];
In the above statement, we get the address of the fist location of the array x and store
it in y. Here “y” is:

a. rvalue
b. xvalue
c. lvalue
d. zvalue
146. 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-
147. Which of the following is the correct conversion of infix to postfix expression? Z+B-(D-H)/K

a. ZB+D-H-K/

b. ZB+DH-K-/

c. ZB+DH-K/-

d. ZB+DHK--/
148. Leaf node of binary search tree contains _________. a. One null pointer

b. Three null pointers

c. Two null pointers

d. All of the given

149. A tree is an AVL tree if

a. Any one node ful fills tha AVL condition


CS301 Midterm Preparation BY PIN2 And MUHAMMAD
(MAS All Rounder)

b. At least half of the nodes fulfill the AVL condition

c. All the nodes fulfill the AVL condition

d. None of the given options


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


151. Memory address is stored in a. Address operator

b. Reference

c. Pointer

d. All of the given


152. A binary tree is said to be a ______ binary tree if every nonleaf node in a binary tree has
non-empty left and right sub trees.
a. Complete
b. Strictly

c. AVL
d. Perfect

153. “+” is a _________operator.


a. Unary
b. Binary
c. Ternary
d. None of the above

154. Which of the following a nonlinear tree


a. Stack
b. Que
c. Tree
d. Linked List

155. For every Process execute the last part of the Memory is for__________of the Program
a. Data
CS301 Midterm Preparation BY PIN2 And MUHAMMAD
(MAS All Rounder)
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
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

160. Circular Linked List Solve the problem of___pointer/method of the doubly link list.
a. Remove
b. Null
c. Add
d. Find
161. isEmpty() method of stack class will return true when.
a. Stack is full
CS301 Midterm Preparation BY PIN2 And MUHAMMAD
(MAS All Rounder)
b. Stack is Partially
c. Stack is not empty or Null
d. Stack is empty
162. “New int[11]” will allocate memory for___integers.
a. 13
b. 12
c. 11
d. 10

163. 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.
a) 1
b) 2
c) 3
d) 4
164. In singly linked list which node will keep track of starting position of the list.

a) Next Node
b) Previous Node
c) Head Node
d) Last Node
165. If we singly linked list to implement list, then there is an issue that it gives difficulty when
we:

a) Move forward in the list


b) Move backward in the list
c) We will increase its size
d) We will decrease its size
166. Can we store elements with different data types in a single array?
a) Yes
b) No
c) In some cases
d) None of the given
167. During union by size method, which data structure is used to improve the balancing of
tree?
a) Array
b) Stack
c) Linked List
CS301 Midterm Preparation BY PIN2 And MUHAMMAD
(MAS All Rounder)
d) Tree
168. The difference between a "Binary Tree (BT)" and a "Binary
Search Tree (BST)" is that,

a) A BST has two children per node whereas a BT can have none, one or two children per
node
b) In BST nodes are inserted based on the values they contain
c) In BT nodes are inserted based on the values they contain
d) There is no difference
169. The main use of AVL tree is:
a) Searching of data
b) Storing of data
c) Insertion of data
d) Security of data
e) The expression
170. if (! heap ->isEmpty() ) checks

a) Heap is empty
b) Heap is full
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
All of the given

177. Stack and Queue can be implemented using ________.

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) 7524
c) 75243
d) 5243
183. In C++, we place the class interface in ________ file. a) .cpp
b) .cppp
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. 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.
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;
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 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
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
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 algorithm 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 ________ neighbor(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
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. “end()” method of list performs its tasks in


a) Many Steps
b) Three Steps
c) One Steps
d) Two Steps
222. Linked List use____to store data.
a) Array
b) Variables
c) Linked Memory
d) 2-D Array
223. Complete the push method code of stack void push (int x) {
A{____}=x}

a) Count++
b) Count—
c) ++count
d) –count
224. A template is a Function or Class that is Written a___data type.
a) Generic
b) None of These
c) Define
d) Specific
225. Trying to remove an element from an empty Stack is called____
a) Garbage Collection
b) Overflow stack
c) Empty collection
d) Underflow of Stack
226. Stack and Queue can be implemented using___
a) Binary Tree
b) Singly Linked List
c) AVL Tree
d) Binary Search Tree
227. 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.
228. we cannot remove items randomly from___
a) Stack
b) Queue
c) Stack and Queue
d) List
229. 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
230. 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/
231. 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
232. 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
233. Last Node in Circular Linked list Contains.
a) Maximum Two points
b) No Null Pointer
c) Atleast one Null pointer
d) None
234. 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
235. 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

236. Generally there is/are _________ case(s) to delete a node from BST.
a) 1
b) 2
c) 3
d) 4
237. . Which of the following is TRUE about recursive calls
a) There is no terminating condition in recursive calls

238. . What will be the output of following code?


Void explode(int& num)

{ Num++;} Main() { Int


power = 15;
explode(power);

b) 16
c) 14
d) 17
e) 15
239. From Operating System point of view, the recursive function calls are made with the
help of __________.
a) Binary Search Tree
b) Stack
c) Query
d) Linked List
240. Analyze the given code carefully and identify which type of binary tree traversal this is;
Void traversal ( treeNode*treeNode)

{ if(treeNode !=Null)

{ cout << *(treeNode->getinfo( ))<< “ ”; Traversal ( treeNode-

>getleft( )); Traversal ( treeNode->getRight( )); } }

a) Inorder
b) Preorder
c) Postorder
d) Sorted Order
241. Which of the following is correct syntax to declare a const function?
• Const int& findMin();
• Int& FindMinconst();
• Int& findMin() const;

242. In binary search tree deleting a node is easy if it is a


_______________ node

a) ROOT
b) LEFT
c) RIGT
d) LEAF

243. If we delete node 2 from the given BST then which node will replace it?

• 1
• 2
• 3
• 4
244. The structure of tree with _________ data is like a linked list.
• Sorted
• Small Large
• Unsorted
245. We can make a lexicographic order of characters based on their _____________.
RANDOM choice

• ASCII values
• Binary DIGITS
• Memory Address

246. The _______of every node should be 1, 0 or -1 otherwise, it will not be an AVL tree.
• Length
• Balance
• Width
• Size

247. What will be the inorder traversal of the given tree?

• 15 25 35 45 75
• 25 15 35 45 75
• 75 35 25 15 45

248. The __________ sign before the name of the variable means that the address of the
variable is beingpassed :
• ||
• ::
• &
• #
249. What will be the return type of the findMin method in the statement given
below?int& findMin( ) const;
• Integers Variable
• Integer Refrence
• Constant Integer
• Integer Pointer
250. Which of the following data structure is/are linear type?
• AVL Tree
• Graphs
• Binary Search Tree
• Heap and Stack

251. Whenever a node is deleted from a binary search tree, _____________ has to be
maintained.
• In Order Traversal
• Any Traversal can be maintained
• Post order Traversal
• Pre order Traversal

252. In the perspective of memory organization each process is divided into _______
sections.
• 2
• 5
• 4
• 3

253. To create a reference variable we need to use ______ sign.


• Ampersand
• Dollar
• Asterisk
• sigma
254. _____ of an empty AVL tree is defined to be -1
• Height
• Size
• Width
• Length
255. In level-order traversal for Binary Search Tree, __________ data structure is used.
• Queue
• Linked List
• Stack
Heap

256. At a particular node, the difference in heights of its left and right subtree gives the
_________ of thenode
• Right Subtree
• Balance
• Left Subtree
• Height
257. If we return the reference of a local variable from a function it will cause :
• Refrence Overloading
• Duplication of local variables
• Deletion of local variables from memory
• Dangling refrence
258. We can calculate the ___________ of a subtree by counting its levels from the
bottom.
• Height
• Data Items
• Nodes
• Balance

259. In a strictly complete binary tree the number of _ at any level k will be 2k .
• Link
• Nodes
• Children
• Sets
260. In Preorder traversal of a binary tree the second step is
____________
• Traverse the right subtree
• Traverse the root
• Traverse the leaf nodes
• Traverse the left subtree

261. Level-order traversal for Binary Search Tree can be implemented, ___

262. The _____ symbol is used when we want to get the value of a variable using pointer.
• *
• ||
• #
• ::
263. After deletion of a node from a binary search tree _______ traversal method should
be maintained.
• Inorder
• Post order
• Level Order
• Preorder
264. We can use Binary Search Tree with _________________
• Integer Data only
• String Data Only
• Both
• Non-Integer Data Inly
265. In which traversal method root node is visited at last step
• Postorder
• Level order
• Inorder
• Preorder
266. If a function has recursive call as the last statement, it is known as __________.
• Function recursion
• Tail recursion
• Last recursion
• Local Recursion

267. The process of getting the value of a variable using pointers is called:
• Dereferencing
• Refrencing Memory Deallocation
• Memory allocation
268. parameter passing (by value or by reference) is similar to PASCAL.
• C++
• COBOL
• JAVA
• FORTRAN

269. Which one of the following case is the most complicated case to delete a node from
BST?
• Node to be deleted has both the left and right children
• Node to be deleted has both the left children
• NONE

270. When a function calling itself is called as __________.


• Inline
• Recursion
• Iteration
• Nested Loo
271. is used for Reference variables in C+
• &
• @ # !

272. Function signatures are also called :


• Function Prototype
• Function Overloading
• Function Defination
• Function Overriding

273. Link List can be special case of,


• Parse Tree
• AVL tree
• Binary Search Tree
CS301 Midterm Preparation BY PIN2 And MUHAMMAD
(MAS All Rounder)
• Heap

1. An efficient program executes ________and helps ___________the usage of resources like


memory, disk.
a. Faster , minimize
b. Slower, maximize
c. Faster, maximize
d. Minimize, faster
2. As computer applications are becoming__________, so there is need for more resources
a. Efficient
b. Complex
c. Simple
d. None of given
3. Within an organization data should be arranged in a way that it is easily_____________. a.
Control
b. Secure
c. Accessible
d. Destroyed
4. The correct syntax to declare of array of 06 elements is?
a. int x[6];
b. int x[5];
c. int x{6};
d. int x{5};
5. An array is collection of cells of the ___________________type.
a. Different
b. Same
c. Integer
d. String
6. Array occupies _____________memory area in the computer.
a. Separate
b. Collective
c. Different
d. Contiguous
7. Which of these best describes an array?
a) A data structure that shows a hierarchical behavior
b) Container of objects of similar types
c) Arrays are immutable once initialized
d) Array is not a data structure

CS301 Midterm Preparation BY PIN2 And MUHAMMAD


(MAS All Rounder)
CS301 Midterm Preparation BY PIN2 And MUHAMMAD
(MAS All Rounder)
8. How do you initialize an array in C?
a) int arr[3] = (1,2,3);
b) int arr(3) = {1,2,3};
c) int arr[3] = {1,2,3};
d) int arr(3) = (1,2,3);
9. The _________ data structure is among the most generic of data structures. a. Array
b. List
c. Stacks
d. Queues
10. List is a set of elements in an/a ________________ order.
a. Exponential
b. Static
c. Dynamic
d. Linear
11. A List is collection of item of the ___________________type.
a. Different
b. Same
c. Integer
d. String
12. The function of clear(); perform what in List data structure ?
a. Remove element at some position in the list
b. Set one list to be a copy of another
c. Clear a list (remove all elements)
d. None of the given
13. It is not necessary to always start the indexing from zero. Sometimes, it is required to start the
indexing from 1.
a. True
b. False
14. In this method, we do not add a new element to the list but simply move the pointer one
element ahead.
a. start()
b. tail()
c. next()
d. back()
15. When does the ArrayIndexOutOfBoundsException occur?
a) Compile-time
b) Run-time
c) Not an error
d) Not an exception at all
16. 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 ?
a) Queue
CS301 Midterm Preparation BY PIN2 And MUHAMMAD
(MAS All Rounder)
CS301 Midterm Preparation BY PIN2 And MUHAMMAD
(MAS All Rounder)
b) Stack
c) Tree
d) Linked list
17. Process of inserting an element in stack is called ____________
a) Create
b) Push
c) Evaluation
d) Pop
18. The data structure required for Breadth First Traversal on a graph is? a) Stack
b) Array
c) Queue
d) Tree
19. 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
20. What is the time complexity of pop() operation when the stack is implemented using an array?
a) O(1)
b) O(n)
c) O(logn)
d) O(nlogn)
21. It is impossible that one element of the array is located at a memory location while the other
element is located somewhere far from it in the memory.
a. True
b. False
22. When we have declared the size of the array, it is ___________ to increase or decrease it during
the execution of the program.
a. Possible
b. Not possible
c. Depend on the programming language
d. Depend on the compiler
23. While calling a function, we pass values of variables to it. Such functions are known as a. Call by
value
b. Call by reference
c. Call by address
d. Call by location
24. A node comprises ____________ fields.
a. Two
b. One
c. Three
d. Four

CS301 Midterm Preparation BY PIN2 And MUHAMMAD


(MAS All Rounder)
CS301 Midterm Preparation BY PIN2 And MUHAMMAD
(MAS All Rounder)
25. While calling a function, instead of passing the values of variables, we pass address of variables
(location of variables) to the function known as
a. Call by value
b. Call by reference
c. Call by address
d. Call by location
26. The local variables of a function are created on____________.
a. Heap
b. Array

c. call stack
d. Linked List

27. All the variables or objects created in a function that we want to access later are created on
memory heap, sometimes called?

a. Memory bank
b. Heap store
c. Stack

d. free store
28. Heap is an area in computer memory that is allocated ____________________. a. Statically
b. Manually
c. Dynamically
d. Randomly
29. All the objects created using new operator have to be explicitly destroyed using the _________.
a. delete operator
b. kill operator
c. remove operator
d. clear operator
30. Nameless objects (objects accessed by pointers) are called _______________.
a. Free object
b. Pointer object
c. anonymous objects
d. none of given
31. 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 ? a) Queue
b) Stack
c) Tree
d) Linked list
32. Which one of the following is an application of Queue Data Structure?
(A) When a resource is shared among multiple consumers.
(B) When data is transferred asynchronously (data not necessarily received at same rate as sent)
between two processes (C) Load Balancing
CS301 Midterm Preparation BY PIN2 And MUHAMMAD
(MAS All Rounder)
CS301 Midterm Preparation BY PIN2 And MUHAMMAD
(MAS All Rounder)
(D) All of the above
33. The data structure required for Breadth First Traversal on a graph is? a) Stack
b) Array
c) Queue
d) Tree
34. A queue follows __________
a) FIFO (First In First Out) principle
b) LIFO (Last In First Out) principle
c) Ordered array
d) Linear tree
35. Circular Queue is also known as ________
a) Ring Buffer
b) Square Buffer
c) Rectangle Buffer
d) Curve Buffer
36. 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
37. A data structure in which elements can be inserted or deleted at/from both the ends but not in
the middle is? a) Queue
b) Circular queue
c) Dequeue
d) Priority queue
38. A normal queue, if implemented using an array of size MAX_SIZE, gets full when
a) Rear = MAX_SIZE – 1
b) Front = (rear + 1)mod MAX_SIZE
c) Front = rear + 1
d) Rear = front
39. Queues serve major role in ______________
a) Simulation of recursion
b) Simulation of arbitrary linked list
c) Simulation of limited resource allocation
d) Simulation of heap sort
40. Which of the following is not the type of queue?
a) Ordinary queue
b) Single ended queue
c) Circular queue
d) Priority queue
41. How many stacks are needed to implement a queue? Consider the situation where no other
data structure like arrays, linked list is available to you.
(A) 1
(B) 2
CS301 Midterm Preparation BY PIN2 And MUHAMMAD
(MAS All Rounder)
CS301 Midterm Preparation BY PIN2 And MUHAMMAD
(MAS All Rounder)
(C) 3
(D) 4
42. Choose correct output for the following sequence of operations.

push(5) push(8)
pop push(2)
push(5) pop pop
pop push(1) pop

a) 85251
b) 85521
c) 82551
d) 81255
43. Stack can be implemented using ___________ and ______________?
a. Array & Binary Tree
b. Linked List & Graph
c. Array & Linked list
d. Queue & linked list
44. Postfix form of following expression.
a. EF*D+
b. DEF*+
c. DEF+*
d. EFD*+
45. When function calls another function then the details of previous function are stored in Stack?
a. True
b. False

46. Insertion and Deletion operation in Queue is known as


a. Push & Pop
b. Enqueue & Dequeue
c. Insert & Delete
d. None of given
47. Stack data structure cannot be used for
a. Implementation of recursive function
b. Allocation resource & scheduling
c. Reversing string
d. Evaluations of string in postfix form
48. What is the advantage of recursive approach than an iterative approach?
a) Consumes less memory
b) Less code and easy to implement
c) Consumes more memory

CS301 Midterm Preparation BY PIN2 And MUHAMMAD


(MAS All Rounder)
CS301 Midterm Preparation BY PIN2 And MUHAMMAD
(MAS All Rounder)
d) More code has to be written
49. In which of the cases uniform binary search fails compared to binary search?
a) A table lookup is generally faster than an addition and a shift
b) Many searches will be performed on the same array
c) Many searches will be performed on several arrays of the same length
d) Complexity of code
50. Given an input arr = {2,5,7,99,899}; key = 899; What is the level of recursion? a) 5
b) 2
c) 3
d) 4
51. What is the worst case complexity of binary search using recursion?
a) O(nlogn)
b) O(logn)
c) O(n)
d) O(n2)
52. What is the average case time complexity of binary search using recursion? a) O(nlogn)
b) O(logn)
c) O(n)
d) O(n2)
53. Which of the following is not an application of binary search?
a) To find the lower/upper bound in an ordered sequence
b) Union of intervals
c) Debugging
d) To search in unordered list
54. Binary Search can be categorized into which of the following?
a) Brute Force technique
b) Divide and conquer
c) Greedy algorithm
d) Dynamic programming
55. Given an array arr = {5,6,77,88,99} and key = 88; How many iterations are done until the
element is found? a) 1
b) 3
c) 4
d) 2
56. Each element of a binary tree is called a ___________of the tree.
a. Node
b. Leaf
c. Mode
d. Child
57. We make (draw) a tree by joining different nodes with lines. But we ______join any nodes
whichever we want to each other.
a. Can also
b. Cannot

CS301 Midterm Preparation BY PIN2 And MUHAMMAD


(MAS All Rounder)
CS301 Midterm Preparation BY PIN2 And MUHAMMAD
(MAS All Rounder)
c. Depend on the nodes
d. None of given
58. In a tree there is always _________ path to go (from root) to a node.
a. Two
b. One
c. No path
d. None of the given
59. We can use the words descendant and child interchangeably.
a. True
b. False
60. A binary tree is said to be a strictly binary tree if every non-leaf node in a binary tree has
nonempty left and right sub trees.
a. True
b. False
61. Level of any other node is one more than the level its_______________. a. Child
b. Leaf
c. Descendant
d. Parent
62. A complete binary tree of depth d is the strictly binary tree all of whose leaves are at level d”. a.
True
b. False

63. We can say that in a complete binary tree at a particular level k, the number of nodes is equal to
_________?
a. 2K
b. 2*2k
c. 2logk
d. 2k
64. Which of the following is not an operation on binary tree?
a. right(p) returns pointer to right sub tree
b. parent(p) returns the father of p
c. brother(p) returns brother of p.
d. all of the given
65. A complete binary tree is necessarily a strictly binary tree but not vice versa. a. True
b. False

66. Binary tree is useful structure when two-way decisions are made at each point. a. True
b. False

67. What is an AVL tree?


a) a tree which is balanced and is a height balanced tree
b) a tree which is unbalanced and is a height balanced tree
c) a tree with three children
d) a tree with at most 3 children

CS301 Midterm Preparation BY PIN2 And MUHAMMAD


(MAS All Rounder)
CS301 Midterm Preparation BY PIN2 And MUHAMMAD
(MAS All Rounder)
68. Why we need to a binary tree which is height balanced?
a) to avoid formation of skew trees
b) to save memory
c) to attain faster memory access
d) to simplify storing
69. In post order traversal of binary tree right sub tree is traversed before visiting root. a) True
b) False

70. What is the possible number of binary trees that can be created with 3 nodes, giving the
sequence N, M, L when traversed in post-order. a) 15
b) 3
c) 5
d) 8
71. Which of the following pair’s traversals on a binary tree can build the tree uniquely?
a) post-order and pre-order
b) post-order and in-order
c) post-order and level order
d) level order and preorder
72. To obtain a prefix expression, which of the tree traversals is used?
a) Level-order traversal
b) Pre-order traversal
c) Post-order traversal
d) In-order traversal
73. Which one is a self- referential data type?
a. Stack
b. Queue
c. Link list
d. All of these
74. Each node in doubly link list has,
a. 1 pointer
b. 2 pointers (Page 39)
c. 3 pointers
d. 4 pointers
75. I have implemented the queue with a linked list, keeping track of a front pointer and a rear
pointer. Which of these pointers will change during an insertion into an EMPTY queue?
a. Neither changes
b. Only front pointer changes.
c. Only rear pointer changes.
d. Both change.
76. The nodes with no successor are called _________
a. Root Nodes
b. Leaf Nodes
c. Both of these
d. None of these
CS301 Midterm Preparation BY PIN2 And MUHAMMAD
(MAS All Rounder)
CS301 Midterm Preparation BY PIN2 And MUHAMMAD
(MAS All Rounder)
77. Doubly Linked List always has one NULL pointer.
a. True
b. False (Page 43)
78. In which of the traversal method, the recursive calls can be used to traverse a binary tree ?

a. In preorder traversal only (Page 143)


b. In inorder traversal only
c. In postorder traversal only
d. All of the given options
79. What is the maximum height of an AVL tree with p nodes?

a) p

b) log(p)
c) log(p)/2
d) p⁄2
80. A tree is an AVL tree if

a. Any one node fulfills the AVL condition


b. At least half of the nodes fulfill the AVL condition

c. All the nodes fulfill the AVL condition (Page 213)


d. None of the given options

81. Consider the following sequence of push operations in a stack:


stack.push(’7’); stack.push(’8’); stack.push(’9’); stack.push(’10’);
stack.push(’11’); stack.push(’12’);

a. 7 8 9 10 11 12
b. 9 8 11 10 7 12
c. 9 10 8 11 12 7
d. 9 10 8 12 7 11
82. Which one of the following operators has higher priority than all of others?

a. Multiplication operator
b. Minus operator
c. Plus operator
d. Exponentiation operator
83. Which of the following is "TRUE" about arrays,
a. We can increase the size of arrays after their creation.
b. We can decrease the size of arrays after their creation.
c. We can increase but can't decrease the size of arrays after their creation.
d. We can neither increase nor decrease the array size after their creation.
84. Next item in a linked list is known as
CS301 Midterm Preparation BY PIN2 And MUHAMMAD
(MAS All Rounder)
CS301 Midterm Preparation BY PIN2 And MUHAMMAD
(MAS All Rounder)
a. Index
b. Item

c. Node
d. Child
85. Each operator in a postfix expression refers to the previous ________ operand(s). a.
One

b. Two
c. Three
d. Four
86. We access elements in AVL Tree in,
a. Linear way only

b. Non Linear way only


c. Both linear and non linear ways
d. None of the given options.
87. A + B * C the postfix expression is _____________?
a. + A * B C
b. +*ABC
c. A B C * +
d. A+*BC
88. Data compression plays a significant role in ________________?
a. Application software
b. Database
c. Encoding scheme

d. computer networks
89. Huffman code is method for the compression of standard text documents. a. True
b. False
90. _________ is a data structure that can grow easily dynamically at run time without
having to copy existing elements.
a. Array

b. List
c. Both of these
d. None of these
91. “+” is a _________operator.
a. Unary

b. Binary
c. Ternary

CS301 Midterm Preparation BY PIN2 And MUHAMMAD


(MAS All Rounder)
CS301 Midterm Preparation BY PIN2 And MUHAMMAD
(MAS All Rounder)
d. None of the above
92. A ___________ is a FIFO structure, which can make the level-order traversal easier. a.
Array
b. List

c. Queue
d. Linked List
93. We can make a lexicographic order of characters based on their ASCII values.

a. True
b. False
94. A queue is a ________data structure, whereas a stack is a ________data structure. a.
FIFO, LIFO
b. LIFO,FIFO
c. none of these
d. both of these
95. Searching an element in an AVL tree take maximum _______ time (where n is no. of
nodes in
AVL tree),
a. Log2(n+1)
b. Log2(n+1) -1

c. 1.44 Log2n
d. 1.66 Log2n
96. Consider the following infix expression.
5 + 6/2
If one converts the above expression into postfix, what would be the resultant expression? a)
56/ + 2

b) 5 6 2 / + not confirmed
c) 5 6 / 2 +
d) /62 + 5
97. Which of the following is a nonlinear data structure?
a. Linked List
b. Stack
c. Queue

d. Tree
98. In an AVL tree to delete a parent with two childs in a straight line following rotations will be
required:-
a. Single

CS301 Midterm Preparation BY PIN2 And MUHAMMAD


(MAS All Rounder)
CS301 Midterm Preparation BY PIN2 And MUHAMMAD
(MAS All Rounder)
b. Double
c. Triple
d. None.
99. Each node in a BST has ______ Pointers:-
a. 1

b. 2
c. 3
d. 4
100. When an operator is used in between two operands this is which type of notation a.
Prefix
b. Postfix

c. Infix
d. None of the Above

FOR ANY VU STUDY RELATED PROBLEM


CONTACT US: 03024731376

CS301 Midterm Preparation BY PIN2 And MUHAMMAD


(MAS All Rounder)
CS301 Midterm Preparation BY PIN2 And MUHAMMAD
(MAS All Rounder)
All vu data (midterm final term+
assignments +quiz + GDB +) and also
WAQAR + MOAZ +TEAM HADI + VU
TOPPER RM AND ALL OTHER STUDENTS
FILES VISIT
https://masallrounder.blogspot.com/

CS301 Midterm Preparation BY PIN2 And MUHAMMAD


(MAS All Rounder)

You might also like