0% found this document useful (0 votes)
163 views141 pages

DS All Units MCQ

This document contains 100 multiple choice questions about data structures and algorithms. Specifically, it covers topics like hash tables, hash functions, collision handling techniques, direct addressing, sorting algorithms like merge sort, quicksort, heap sort, and insertion sort. It also includes questions about search algorithms like binary search and their time complexities.
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)
163 views141 pages

DS All Units MCQ

This document contains 100 multiple choice questions about data structures and algorithms. Specifically, it covers topics like hash tables, hash functions, collision handling techniques, direct addressing, sorting algorithms like merge sort, quicksort, heap sort, and insertion sort. It also includes questions about search algorithms like binary search and their time complexities.
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/ 141

100 MCQ on UNIT 5

1. What is a hash table?


a) A structure that maps values to keys
b) A structure that maps keys to values
c) A structure used for storage
d) A structure used to implement stack and queue
Answer: b
2. If several elements are competing for the same bucket in the hash table, what is it called?
a) Diffusion
b) Replication
c) Collision
d) Duplication
Answer: c
3.What is direct addressing?
a) Distinct array position for every possible key
b) Fewer array positions than keys
c) Fewer keys than array positions
d) Same array position for all keys
4. What is the search complexity in direct addressing?
a) O(n)
b) O(logn)
c) O(nlogn)
d) O(1)
Answer: d
5. What is a hash function?
a) A function has allocated memory to keys
b) A function that computes the location of the key in the array
c) A function that creates an array
d) A function that computes the location of the values in the array
Answer: b
6. Which of the following is not a technique to avoid a collision?
a) Make the hash function appear random
b) Use the chaining method
c) Use uniform hashing
d) Increasing hash table size
Answer: d
7. What is the hash function used in the division method?
a) h(k) = k/m
b) h(k) = k mod m
c) h(k) = m/k
d) h(k) = m mod k
Answer: b
8. What can be the value of m in the division method?
a) Any prime number
b) Any even number
c) 2p – 1
d) 2p
Answer: a
9. Which scheme provides good performance?
a) open addressing
b) universal hashing
c) hashing by division
d) hashing by multiplication
Answer: b
10. Using division method, in a given hash table of size 157, the key of value 172 be placed
at position ____
a) 19
b) 72
c) 15
d) 17
Answer: c
11. Collisions can be reduced by choosing a hash function randomly in a way that is
independent of the keys that are actually to be stored.
a) True
b) False
Answer: a
12. The worst-case occur in linear search algorithm when …….
A. Item is somewhere in the middle of the array
B. Item is not in the array at all
C. Item is the last element in the array
D. Item is the last element in the array or item is not there at all
Answer: d
13. If the number of records to be sorted is small, then …… sorting can be efficient.
A. Merge
B. Heap
C. Selection
D. Bubble
Answer: C.
14) The complexity of the sorting algorithm measures the …… as a function of the number n of
items to be sorter.
A. average time
B. running time
C. average-case complexity
D. case-complexity
Answer:b
15) Which of the following is not a limitation of binary search algorithm?
A. must use a sorted array
B. requirement of sorted array is expensive when a lot of insertion and deletions are needed
C. there must be a mechanism to access middle element directly
D. binary search algorithm is not efficient when the data elements more than 1500.

Answer:d

16) The Average case occurs in the linear search algorithm ……….
A. when the item is somewhere in the middle of the array
B. when the item is not the array at all
C. when the item is the last element in the array
D. Item is the last element in the array or item is not there at all
Answer:a
17) Binary search algorithm cannot be applied to …
A. sorted linked list
B. sorted binary trees
C. sorted linear array
D. pointer array

Answer:a

18) Complexity of linear search algorithm is ………


A. O(n)
B. O(logn)
C. O(n2)
D. O(n logn)

Answer:a

19) Sorting algorithm can be characterized as ……


A. Simple algorithm which require the order of n2 comparisons to sort n items.
B. Sophisticated algorithms that require the O(nlog2n) comparisons to sort items.
C. Both of the above
D. None of the above

Answer:c

20) The complexity of bubble sort algorithm is …..

A. O(n)
B. O(logn)
C. O(n2)
D. O(n logn)
Answer:c

21) State True or False for internal sorting algorithms.


i) Internal sorting are applied when the entire collection if data to be sorted is small enough that the
sorting can take place within main memory.
ii) The time required to read or write is considered to be significant in evaluating the performance of
internal sorting.
A. i-True, ii-True
B. i-True, ii-False
C. i-False, ii-True
D. i-False, ii-False

Answer:b

22) The complexity of merge sort algorithm is ……


A. O(n)
B. O(logn)
C. O(n2)
D. O(n logn)
Answer:d
23) ………. is putting an element in the appropriate place in a sorted list yields a larger sorted order
list.
A. Insertion
B. Extraction
C. Selection
D. Distribution

Answer:a

24) …………order is the best possible for array sorting algorithm which sorts n item.

A. O(n logn)
B. O(n2)
C. O(n+logn)
D. O(logn)

Answer:c

25) ……… is rearranging pairs of elements which are out of order, until no such pairs remain.
A. Insertion
B. Exchange
C. Selection
D. Distribution

Answer:b

26) ………… is the method used by card sorter.


A. Radix sort
B. Insertion
C. Heap
D. Quick

Answer:a

27) Which of the following sorting algorithm is of divide and conquer type?
A. Bubble sort
B. Insertion sort
C. Merge sort
D. Selection sort

Answer:c

28) …….. sorting algorithm is frequently used when n is small where n is total number of elements.
A. Heap

B. Insertion
C. Bubble
D. Quick

Answer:b

29) Which of the following sorting algorithm is of priority queue sorting type?
A. Bubble sort
B. Insertion sort
C. Merge sort
D. Selection sort

Answer:d
30) Which of the following is not the required condition for a binary search algorithm?
A. The list must be sorted
B. There should be direct access to the middle element in any sublist
C. There must be a mechanism to delete and/or insert elements in the list.
D. Number values should only be present

Answer:c

31) Partition and exchange sort is ……..


A. quick sort
B. tree sort
C. heap sort
D. bubble sort

Answer:a
32. Which of the following is not a stable sorting algorithm?

a) Insertion sort
b) Selection sort
c) Bubble sort
d) Merge sort
ANSWER: B
33.Which of the following is a stable sorting algorithm?

a) Merge sort
b) Typical in-place quick sort
c) Heap sort
d) Selection sort
34. Which of the following is not an in-place sorting algorithm?

a) Selection sort
b) Heap sort
c) Quick sort
d) Merge sort
ANSWER: D
35.Running merge sort on an array of size n which is already sorted is

a) O(n)
b) O(nlogn)
c) O(n2)
d) None
ANSWER: B
36.The time complexity of a quick sort algorithm which makes use of median, found by
an O(n) algorithm, as pivot element is

a) O(n2)
b) O(nlogn)
c) O(nloglogn)
d) O(n)
ANSWER: B
37.If the given input array is sorted or nearly sorted, which of the following algorithm
gives the best performance?

a) Insertion sort
b) Selection sort
c) Quick sort
d) Merge sort
ANSWER: A
38.Time complexity of bubble sort in best case is

a) θ (n)
b) θ (nlogn)
c) θ (n2)
d) θ (n(logn) 2)
ANSWER: A
39.Time complexity to sort elements of binary search tree is

a) O(n)
b) O(nlogn)
c) O(n2)
d) O(n2logn)
ANSWER: A
40.Which of the following algorithm design technique is used in the quick sort
algorithm?

a) Dynamic programming
b) Backtracking
c) Divide-and-conquer
d) Greedy method
ANSWER: C
41.Merge sort uses

a) Divide-and-conquer
b) Backtracking
c) Heuristic approach
d) Greedy approach
ANSWER: A
42. For merging two sorted lists of size m and n into sorted list of size m+n, we require
comparisons of

a) O(m)
b) O(n)
c) O(m+n)
d) O(logm + logn)
ANSWER: C
43.What is the worst case complexity of bubble sort?
a) O(nlogn)
b) O(logn)
c) O(n)
d) O(n2)
Answer: d
44. Select the appropriate code that performs bubble sort.
a)

for(int j=arr.length-1; j>=0; j--)


{
for(int k=0; k<j; k++)
{
if(arr[k] > arr[k+1])
{
int temp = arr[k];
arr[k] = arr[k+1];
arr[k+1] = temp;
}
}
}
b)

for(int j=arr.length-1; j>=0; j--)


{
for(int k=0; k<j; k++)
{
if(arr[k] < arr[k+1])
{
int temp = arr[k];
arr[k] = arr[k+1];
arr[k+1] = temp;
}
}
}
c)

for(int j=arr.length; j>=0; j--)


{
for(int k=0; k<j; k++)
{
if(arr[k] > arr[k+1])
{
int temp = arr[k];
arr[k] = arr[k+1];
arr[k+1] = temp;
}
}
}
d)

for(int j=arr.length; j>=0; j--)


{
for(int k=0; k<j; k++)
{
if(arr[k] > arr[k+2])
{
int temp = arr[k];
arr[k] = arr[k+1];
arr[k+1] = temp;
}
}
}
Answer: a

45.What is the average case complexity of bubble sort?


a) O(nlogn)
b) O(logn)
c) O(n)
d) O(n2)
Answer: d
46.The given array is arr = {1, 2, 4, 3}. Bubble sort is used to sort the array elements. How
many iterations will be done to sort the array?
a) 4
b) 2
c) 1
d) 0
Answer: a
47.How many passes does an insertion sort algorithm consist of?
a) N
b) N-1
c) N+1
d) N2
Answer: b

48.Which of the following algorithm implementations is similar to that of an insertion sort?


a) Binary heap
b) Quick sort
c) Merge sort
d) Radix sort
Answer: a
49.What is the average case running time of an insertion sort algorithm?
a) O(N)
b) O(N log N)
c) O(log N)
d) O(N2)
Answer: d
50.What is the running time of an insertion sort algorithm if the input is pre-sorted?
a) O(N2)
b) O(N log N)
c) O(N)
d) O(M log N)
Answer: c
51.What will be the number of passes to sort the elements using insertion sort?
14, 12,16, 6, 3, 10
a) 6
b) 5
c) 7
d) 1
Answer: b
52.Which of the following real time examples is based on insertion sort?
a) arranging a pack of playing cards
b) database scenarios and distributes scenarios
c) arranging books on a library shelf
d) real-time systems
Answer: a
53.In C, what are the basic loops required to perform an insertion sort?
a) do- while
b) if else
c) for and while
d) for and if
Answer: c
54. Which of the following sorting algorithms is the fastest for sorting small arrays?
a) Quick sort
b) Insertion sort
c) Shell sort
d) Heap sort
Answer: b
55.For the best case input, the running time of an insertion sort algorithm is?
a) Linear
b) Binary
c) Quadratic
d) Depends on the input
56.Which of the following examples represent the worst case input for an insertion sort?
a) array in sorted order
b) array sorted in reverse order
c) normal unsorted array
d) large array
Answer: b
57. Which of the following is not in place sorting algorithm?
a) merge sort
b) quick sort
c) heap sort
d) insertion sort
Answer: a
58. Which of the following is not a stable sorting algorithm?
a) Quick sort
b) Cocktail sort
c) Bubble sort
d) Merge sort
Answer: a
59. Which of the following stable sorting algorithm takes the least time when applied to an
almost sorted array?
a) Quick sort
b) Insertion sort
c) Selection sort
d) Merge sort
Answer: d
60. Merge sort is preferred for arrays over linked lists.
a) true
b) false
Answer: b
61. Choose the correct code for merge sort.
a)

void merge_sort(int arr[], int left, int right)


{
if (left > right)
{

int mid = (right-left)/2;


merge_sort(arr, left, mid);
merge_sort(arr, mid+1, right);

merge(arr, left, mid, right); //function to merge sorted arrays


}
}
b)

void merge_sort(int arr[], int left, int right)


{
if (left < right)
{

int mid = left+(right-left)/2;


merge_sort(arr, left, mid);
merge_sort(arr, mid+1, right);

merge(arr, left, mid, right); //function to merge sorted arrays


}
}
c)

void merge_sort(int arr[], int left, int right)


{
if (left < right)
{

int mid = left+(right-left)/2;


merge(arr, left, mid, right); //function to merge sorted arrays
merge_sort(arr, left, mid);
merge_sort(arr, mid+1, right);

}
}
d)

void merge_sort(int arr[], int left, int right)


{
if (left < right)
{

int mid = (right-left)/2;


merge(arr, left, mid, right); //function to merge sorted arrays
merge_sort(arr, left, mid);
merge_sort(arr, mid+1, right);

}
}
Answer: b
62. Which of the following sorting algorithms is the fastest?
a) Merge sort
b) Quick sort
c) Insertion sort
d) Shell sort
Answer: b
63. Quick sort follows Divide-and-Conquer strategy.
a) True
b) False
Answer: a
64. What is the worst case time complexity of a quick sort algorithm?
a) O(N)
b) O(N log N)
c) O(N2)
d) O(log N)
Answer: c
65. Which of the following methods is the most effective for picking the pivot element?
a) first element
b) last element
c) median-of-three partitioning
d) random element
Answer: c
66. Find the pivot element from the given input using median-of-three partitioning method.
8, 1, 4, 9, 6, 3, 5, 2, 7, 0.
a) 8
b) 7
c) 9
d) 6
Answer: d
67. Which is the safest method to choose a pivot element?
a) choosing a random element as pivot
b) choosing the first element as pivot
c) choosing the last element as pivot
d) median-of-three partitioning method
Answer: a
68. What is the average running time of a quick sort algorithm?
a) O(N2)
b) O(N)
c) O(N log N)
d) O(log N)
Answer: c
69. Which of the following sorting algorithms is used along with quick sort to sort the sub
arrays?
a) Merge sort
b) Shell sort
c) Insertion sort
d) Bubble sort
Answer: c
70. Quick sort uses join operation rather than merge operation.
a) true
b) false
Answer: a
71. How many sub arrays does the quick sort algorithm divide the entire array into?
a) one
b) two
c) three
d) four
Answer: b
72. Which of the following is not an in-place sorting algorithm?

A. Selection sort
B. Heap sort
C. Quick sort
D. Merge sort
Ans : D
73. What is the advantage of bubble sort over other sorting techniques?

A. It is faster
B. Consumes less memory
C. Detects whether the input is already sorted
D. All of the mentioned
Ans : C
74. The complexity of sorting algorithm measures the …… as a function of the number n of
items to be sorter.

A. average time
B. running time
C. average-case complexity
D. case-complexity
Ans : B
75. Suppose we are sorting an array of eight integers using quicksort, and we have just
finished the first partitioning with the array looking like this:
2 5 1 7 9 12 11 10
Which statement is correct?

A. The pivot could be either the 7 or the 9.


B. The pivot could be the 7, but it is not the 9
C. The pivot is not the 7, but it could be the 9
D. Neither the 7 nor the 9 is the pivot.
Ans : A
76. Which is the worst method of choosing a pivot element?
a) first element as pivot
b) last element as pivot
c) median-of-three partitioning
d) random element as pivot
Answer: a
77. Which among the following is the best cut-off range to perform insertion sort within a
quick sort?
a) N=0-5
b) N=5-20
c) N=20-30
d) N>30
Answer: b
78. Where is linear searching used?
a) When the list has only a few elements
b) When performing a single search in an unordered list
c) Used all the time
d) When the list has only a few elements and When performing a single search in an
unordered list
Answer: d
79. Select the code snippet which performs unordered linear search iteratively?
a)

int unorderedLinearSearch(int arr[], int size, int data)


{
int index;
for(int i = 0; i < size; i++)
{
if(arr[i] == data)
{
index = i;
break;
}
}
return index;
}
b)

int unorderedLinearSearch(int arr[], int size, int data)


{
int index;
for(int i = 0; i < size; i++)
{
if(arr[i] == data)
{
break;
}
}
return index;
}
c)

int unorderedLinearSearch(int arr[], int size, int data)


{
int index;
for(int i = 0; i <= size; i++)
{
if(arr[i] == data)
{
index = i;
break;
}
}
return index;
}
d)

int unorderedLinearSearch(int arr[], int size, int data)


{
int index;
for(int i = 0; i < size-1; i++)
{
if(arr[i] == data)
{
index = i;
break;
}
}
return index;
}
Answer: a
80. What is the best case for linear search?
a) O(nlogn)
b) O(logn)
c) O(n)
d) O(1)
Answer: d
81. What is the worst case for linear search?
a) O(nlogn)
b) O(logn)
c) O(n)
d) O(1)
Answer: c
82. What is the best case and worst case complexity of ordered linear search?
a) O(nlogn), O(logn)
b) O(logn), O(nlogn)
c) O(n), O(1)
d) O(1), O(n)
Answer: d
83. What does the following piece of code do?
for (int i = 0; i < arr.length-1; i++)
{
for (int j = i+1; j < arr.length; j++)
{
if( (arr[i].equals(arr[j])) && (i != j) )
{
System.out.println(arr[i]);
}
}
}
a) Print the duplicate elements in the array
b) Print the element with maximum frequency
c) Print the unique elements in the array
d) Prints the element with minimum frequnecy

Answer: a
84. Which of the following is a disadvantage of linear search?
a) Requires more space
b) Greater time complexities compared to other searching algorithms
c) Not easy to understand
d) Not easy to implement
Answer: b
85. 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
d) More code has to be written
Answer: b
86. 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
Answer: c
87. Given an array arr = {45,77,89,90,94,99,100} and key = 99; what are the mid
values(corresponding array elements) in the first and second levels of recursion?
a) 90 and 99
b) 90 and 94
c) 89 and 99
d) 89 and 94
Answer: a
88. What is the worst case complexity of binary search using recursion?
a) O(nlogn)
b) O(logn)
c) O(n)
d) O(n2)
Answer: b
89. What is the average case time complexity of binary search using recursion?
a) O(nlogn)
b) O(logn)
c) O(n)
d) O(n2)
Answer: b
90. 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
Answer: d
91. Binary Search can be categorized into which of the following?
a) Brute Force technique
b) Divide and conquer
c) Greedy algorithm
d) Dynamic programming
Answer: b
92. 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
Answer: d
93. Given an array arr = {45,77,89,90,94,99,100} and key = 100; What are the mid
values(corresponding array elements) generated in the first and second iterations?
a) 90 and 99
b) 90 and 100
c) 89 and 94
d) 94 and 99
Answer: a
94 . What is the time complexity of binary search with iteration?
a) O(nlogn)
b) O(logn)
c) O(n)
d) O(n2)
Answer: b
95. What is the worst case runtime of linear search(recursive) algorithm?
a) O(n)
b) O(logn)
c) O(n2)
d) O(nx)
Answer: a
96. Linear search(recursive) algorithm used in _____________
a) When the size of the dataset is low
b) When the size of the dataset is large
c) When the dataset is unordered
d) Never used
Answer: a
97. The array is as follows: 1,2,3,6,8,10. At what time the element 6 is found? (By using
linear search(recursive) algorithm)
a) 4th call
b) 3rd call
c) 6th call
d) 5th call
Answer: a
98. The array is as follows: 1,2,3,6,8,10. Given that the number 17 is to be searched. At
which call it tells that there’s no such element? (By using linear search(recursive) algorithm)
a) 7th call
b) 9th call
c) 17th call
d) The function calls itself infinite number of times
Answer: a
99. What is the best case runtime of linear search(recursive) algorithm on an ordered set of
elements?
a) O(1)
b) O(n)
c) O(logn)
d) O(nx)
Answer: a
100. Can linear search recursive algorithm and binary search recursive algorithm be
performed on an unordered list?
a) Binary search can’t be used
b) Linear search can’t be used
c) Both cannot be used
d) Both can be used
Answer: a
100 MCQ on Unit 4

1. How many children does a binary tree have?


a) 2
b) any number of children
c) 0 or 1 or 2
d) 0 or 1
Answer: c
2. What is/are the disadvantages of implementing tree using normal arrays?
a) difficulty in knowing children nodes of a node
b) difficult in finding the parent of a node
c) have to know the maximum number of nodes possible before creation of trees
d) difficult to implement
Answer: c
3. What must be the ideal size of array if the height of tree is ‘l’?
a) 2l-1
b) l-1
c) l
d) 2l
Answer: a
4. What are the children for node ‘w’ of a complete-binary tree in an array representation?
a) 2w and 2w+1
b) 2+w and 2-w
c) w+1/2 and w/2
d) w-1/2 and w+1/2
Answer: a
5. What is the parent for a node ‘w’ of a complete binary tree in an array representation when
w is not 0?
a) floor(w-1/2)
b) ceil(w-1/2)
c) w-1/2
d) w/2
Answer: a
6. If the tree is not a complete binary tree then what changes can be made for easy access of
children of a node in the array?
a) every node stores data saying which of its children exist in the array
b) no need of any changes continue with 2w and 2w+1, if node is at i
c) keep a seperate table telling children of a node
d) use another array parallel to the array with tree
Answer: a
7. What must be the missing logic in place of missing lines for finding sum of nodes of
binary tree in alternate levels?

//e.g:-consider -complete binary tree:-height-3, [1,2,3,4,5,6,7]-answer must be 23


n=power(2,height)-1; //assume input is height and a[i] contains tree elements
for(i=1;i<=n;)
{
for(j=1;j<=pow(2,currentlevel-1);j++) //present level is initialized to 1 and sum is
initialized to 0
{
sum=sum+a[i];
i=i+1;
}
//missing logic
}
a)

i=i+pow(2,currentlevel);
currentlevel=currentlevel+2;
j=1;
b)

i=i+pow(2,currentlevel);
currentlevel=currentlevel+2;
j=0;
c)

i=i-pow(2,currentlevel);
currentlevel=currentlevel+2;
j=1;
d)

i=i+pow(2,currentlevel);
currentlevel=currentlevel+1;
j=1;

Answer: a
8. Consider a situation of writing a binary tree into a file with memory storage efficiency in
mind, is array representation of tree is good?
a) yes because we are overcoming the need of pointers and so space efficiency
b) yes because array values are indexable
c) No it is not efficient in case of sparse trees and remaning cases it is fine
d) No linked list representation of tree is only fine
Answer: c
9. Can a tree stored in an array using either one of inorder or post order or pre order traversals
be again reformed?
a) Yes just traverse through the array and form the tree
b) No we need one more traversal to form a tree
c) No in case of sparse trees
d) Yes by using both inorder and array elements
Answer: b
10. Advantages of linked list representation of binary trees over arrays?
a) dynamic size
b) ease of insertion/deletion
c) ease in randomly accessing a node
d) both dynamic size and ease in insertion/deletion
Answer: d
11. Disadvantages of linked list representation of binary trees over arrays?
a) Randomly accessing is not possible
b) Extra memory for a pointer is needed with every element in the list
c) Difficulty in deletion
d) Random access is not possible and extra memory with every element
Answer: d
12. Which of the following traversing algorithm is not used to traverse in a tree?
a) Post order
b) Pre order
c) Post order
d) Randomized
Answer: d
13. Level order traversal of a tree is formed with the help of
a) breadth first search
b) depth first search
c) dijkstra’s algorithm
d) prims algorithm
Answer: a
14. Identify the reason which doesn’t play a key role to use threaded binary trees?
a) The storage required by stack and queue is more
b) The pointers in most of nodes of a binary tree are NULL
c) It is Difficult to find a successor node
d) They occupy less size
Answer: d
15. What may be the psuedo code for finding the size of a tree?
a) find_size(root_node–>left_node) + 1 + find_size(root_node–>right_node)
b) find_size(root_node–>left_node) + find_size(root_node–>right_node)
c) find_size(root_node–>right_node) – 1
d) find_size(root_node–>left_node + 1
Answer: a
16. What is missing in this logic of finding a path in the tree for a given sum (i.e checking
whether there will be a path from roots to leaf nodes with given sum)?

checkSum(struct bin-treenode *root , int sum) :


if(root==null)
return sum as 0
else :
leftover_sum=sum-root_node-->value
//missing
a) code for having recursive calls to either only left tree or right trees or to both subtrees
depending on their existence
b) code for having recursive calls to either only left tree or right trees
c) code for having recursive calls to either only left tree
d) code for having recursive calls to either only right trees

Answer: a
17. What must be the missing logic below so as to print mirror of a tree as below as an
example?

if(rootnode):
mirror(rootnode-->left)
mirror(rootnode-->right)

//missing

end
a) swapping of left and right nodes is missing
b) swapping of left with root nodes is missing
c) swapping of right with root nodes is missing
d) nothing is missing

Answer: a
18. What is the code below trying to print?

void print(tree *root,tree *node)


{
if(root ==null) return 0
if(root-->left==node || root-->right==node || print(root->left,node)||printf(root->right,node)
{
print(root->data)
}
}
a) just printing all nodes
b) not a valid logic to do any task
c) printing ancestors of a node passed as argument
d) printing nodes from leaf node to a node passed as argument

Answer: c
19. What is the maximum number of children that a binary tree node can have?
a) 0
b) 1
c) 2
d) 3
Answer: c
20. The following given tree is an example for?

a) Binary tree
b) Binary search tree
c) Fibonacci tree
d) AVL tree
Answer: a
21. A binary tree is a rooted tree but not an ordered tree.
a) true
b) false
Answer: b
22. How many common operations are performed in a binary tree?
a) 1
b) 2
c) 3
d) 4
Answer: c
23. What is the traversal strategy used in the binary tree?
a) depth-first traversal
b) breadth-first traversal
c) random traversal
d) Priority traversal
Answer: b
24. How many types of insertion are performed in a binary tree?
a) 1
b) 2
c) 3
d) 4
Answer: b
25. What operation does the following diagram depict?

a) inserting a leaf node


b) inserting an internal node
c) deleting a node with 0 or 1 child
d) deleting a node with 2 children
Answer: c
26. General ordered tree can be encoded into binary trees.
a) true
b) false
Answer: a
27. The average depth of a binary tree is given as?
a) O(N)
b) O(√N)
c) O(N2)
d) O(log N)
Answer: d
28. How many orders of traversal are applicable to a binary tree (In General)?
a) 1
b) 4
c) 2
d) 3
Answer: d
29. If binary trees are represented in arrays, what formula can be used to locate a left child, if
the node has an index i?
a) 2i+1
b) 2i+2
c) 2i
d) 4i
Answer: C
30Using what formula can a parent node be located in an array?
a) (i+1)/2
b) (i-1)/2
c) i/2
d) 2i/2
Answer: C
31. Which of the following properties are obeyed by all three tree – traversals?
a) Left subtrees are visited before right subtrees
b) Right subtrees are visited before left subtrees
c) Root node is visited before left subtree
d) Root node is visited before right subtree
Answer: a
32. onstruct a binary tree using the following data.
The preorder traversal of a binary tree is 1, 2, 5, 3, 4. The inorder traversal of the same binary
tree is 2, 5, 1, 4, 3.

a)
b)

c)

d)
Answer: d
33. For the tree below, write the pre-order traversal.

a) 2, 7, 2, 6, 5, 11, 5, 9, 4
b) 2, 7, 5, 2, 6, 9, 5, 11, 4
c) 2, 5, 11, 6, 7, 4, 9, 5, 2
d) 2, 7, 5, 6, 11, 2, 5, 4, 9
Answer: a
34. For the tree below, write the post-order traversal.

a) 2, 7, 2, 6, 5, 11, 5, 9, 4
b) 2, 7, 5, 2, 6, 9, 5, 11, 4
c) 2, 5, 11, 6, 7, 4, 9, 5, 2
d) 2, 7, 5, 6, 11, 2, 5, 4, 9
Answer: c
35. Select the code snippet which performs pre-order traversal.
a)

public void preorder(Tree root)


{
System.out.println(root.data);
preorder(root.left);
preorder(root.right);
}
b)

public void preorder(Tree root)


{
preorder(root.left);
System.out.println(root.data);
preorder(root.right);
}
c)

public void preorder(Tree root)


{
System.out.println(root.data);
preorder(root.right);
preorder(root.left);
}
d)
public void preorder(Tree root)
{
preorder(root.right);
preorder(root.left);
System.out.println(root.data);
}
Answer: a
36. Select the code snippet which performs post-order traversal.
a)
public void postorder(Tree root)
{
System.out.println(root.data);
postorder(root.left);
postorder(root.right);
}
b)

public void postorder(Tree root)


{
postorder(root.left);
postorder(root.right);
System.out.println(root.data);
}
c)

public void postorder(Tree root)


{
System.out.println(root.data);
postorder(root.right);
postorder(root.left);
}
d)

public void postorder(Tree root)


{
postorder(root.right);
System.out.println(root.data);
postorder(root.left);
}

Answer: b
37. Select the code snippet that performs pre-order traversal iteratively.
a)
public void preOrder(Tree root)
{
if (root == null) return;
Stack<Tree> stk = new Stack<Tree>();
st.add(root);
while (!stk.empty())
{
Tree node = stk.pop();
System.out.print(node.data + " ");
if (node.left != null) stk.push(node.left);
if (node.right != null) stk.push(node.right);
}
}
b)

public void preOrder(Tree root)


{
if (root == null) return;
Stack<Tree> stk = new Stack<Tree>();
while (!stk.empty())
{
Tree node = stk.pop();
System.out.print(node.data + " ");
if (node.right != null) stk.push(node.right);
if (node.left != null) stk.push(node.left);
}
}
c)

public void preOrder(Tree root)


{
if (root == null) return;
Stack<Tree> stk = new Stack<Tree>();
st.add(root);
while (!stk.empty())
{
Tree node = stk.pop();
System.out.print(node.data + " ");
if (node.right != null) stk.push(node.right);
if (node.left != null) stk.push(node.left);
}
}
d)

public void preOrder(Tree root)


{
if (root == null) return;
Stack<Tree> stk = new Stack<Tree>();
st.add(root);
while (!stk.empty())
{
Tree node = stk.pop();
System.out.print(node.data + " ");
if (node.right != null) stk.push(node.left);
if (node.left != null) stk.push(node.right);
}
}
Answer: c
38. What is the time complexity of pre-order traversal in the iterative fashion?
a) O(1)
b) O(n)
c) O(logn)
d) O(nlogn)
Answer: b
39. What is the space complexity of the post-order traversal in the recursive fashion? (d is the
tree depth and n is the number of nodes)
a) O(1)
b) O(nlogd)
c) O(logd)
d) O(d)
Answer: d
40. 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
Answer: b
41. Consider the following data. The pre order traversal of a binary tree is A, B, E, C, D. The
in order traversal of the same binary tree is B, E, A, D, C. The level order sequence for the
binary tree is _________
a) A, C, D, B, E
b) A, B, C, D, E
c) A, B, C, E, D
d) D, B, E, A, C
Answer: b
42. Consider the following data and specify which one is Preorder Traversal Sequence,
Inorder and Postorder sequences.
S1: N, M, P, O, Q
S2: N, P, Q, O, M
S3: M, N, O, P, Q
a) S1 is preorder, S2 is inorder and S3 is postorder
b) S1 is inorder, S2 is preorder and S3 is postorder
c) S1 is inorder, S2 is postorder and S3 is preorder
d) S1 is postorder, S2 is inorder and S3 is preorder
Answer: c
43. In postorder traversal of binary tree right subtree is traversed before visiting root.
a) True
b) False
Answer: a
44. 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
Answer: c
45. The post-order traversal of a binary tree is O P Q R S T. Then possible pre-order traversal
will be ________
a) T Q R S O P
b) T O Q R P S
c) T Q O P S R
d) T Q O S P R
Answer: c
46. A binary search tree contains values 7, 8, 13, 26, 35, 40, 70, 75. Which one of the
following is a valid post-order sequence of the tree provided the pre-order sequence as 35, 13,
7, 8, 26, 70, 40 and 75?
a) 7, 8, 26, 13, 75, 40, 70, 35
b) 26, 13, 7, 8, 70, 75, 40, 35
c) 7, 8, 13, 26, 35, 40, 70, 75
d) 8, 7, 26, 13, 40, 75, 70, 35
Answer: d
47. 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
Answer: b
48. A full binary tree can be generated using ______
a) post-order and pre-order traversal
b) pre-order traversal
c) post-order traversal
d) in-order traversal
Answer: a
49. The maximum number of nodes in a tree for which post-order and pre-order traversals
may be equal is ______
a) 3
b) 1
c) 2
d) any number
Answer: b
50. The steps for finding post-order traversal are traverse the right subtree, traverse the left
subtree or visit the current node.
a) True
b) False
Answer: b
51. The pre-order and in-order are traversals of a binary tree are T M L N P O Q and L M N
T O P Q. Which of following is post-order traversal of the tree?
a) L N M O Q P T
b) N M O P O L T
c) L M N O P Q T
d) O P L M N Q T
Answer: a
52. Find the postorder traversal of the binary tree shown below.

a) P Q R S T U V W X
b) W R S Q P V T U X
c) S W T Q X U V R P
d) S T W U X V Q R P
Answer: c
53. For the tree below, write the in-order traversal.

a) 6, 2, 5, 7, 11, 2, 5, 9, 4
b) 6, 5, 2, 11, 7, 4, 9, 5, 2
c) 2, 7, 2, 6, 5, 11, 5, 9, 4
d) 2, 7, 6, 5, 11, 2, 9, 5, 4
Answer: a
54. For the tree below, write the level-order traversal.

a) 2, 7, 2, 6, 5, 11, 5, 9, 4
b) 2, 7, 5, 2, 11, 9, 6, 5, 4
c) 2, 5, 11, 6, 7, 4, 9, 5, 2
d) 2, 7, 5, 6, 11, 2, 5, 4, 9
Answer: b
55. What is the space complexity of the in-order traversal in the recursive fashion? (d is the
tree depth and n is the number of nodes)
a) O(1)
b) O(nlogd)
c) O(logd)
d) O(d)
Answer: d
56. What is the time complexity of level order traversal?
a) O(1)
b) O(n)
c) O(logn)
d) O(nlogn)
Answer: b
57. Which of the following graph traversals closely imitates level order traversal of a binary
tree?
a) Depth First Search
b) Breadth First Search
c) Depth & Breadth First Search
d) Binary Search
Answer: b
58. In a binary search tree, which of the following traversals would print the numbers in the
ascending order?
a) Level-order traversal
b) Pre-order traversal
c) Post-order traversal
d) In-order traversal
Answer: d
59. The number of edges from the root to the node is called __________ of the tree.
a) Height
b) Depth
c) Length
d) Width
Answer: b
60. The number of edges from the node to the deepest leaf is called _________ of the tree.
a) Height
b) Depth
c) Length
d) Width
Answer: a
61. What is a full binary tree?
a) Each node has exactly zero or two children
b) Each node has exactly two children
c) All the leaves are at the same level
d) Each node has exactly one or two children
Answer: a
62. What is a complete binary tree?
a) Each node has exactly zero or two children
b) A binary tree, which is completely filled, with the possible exception of the bottom level,
which is filled from right to left
c) A binary tree, which is completely filled, with the possible exception of the bottom level,
which is filled from left to right
d) A tree In which all nodes have degree 2
Answer: c
63. What is the average case time complexity for finding the height of the binary tree?
a) h = O(loglogn)
b) h = O(nlogn)
c) h = O(n)
d) h = O(log n)
Answer: d
64. Which of the following is not an advantage of trees?
a) Hierarchical structure
b) Faster search
c) Router algorithms
d) Undo/Redo operations in a notepad
Answer: d
65. In a full binary tree if number of internal nodes is I, then number of leaves L are?
a) L = 2*I
b) L = I + 1
c) L = I – 1
d) L = 2*I – 1
Answer: b
66. Which of the following is incorrect with respect to binary trees?
a) Let T be a binary tree. For every k ≥ 0, there are no more than 2k nodes in level k
b) Let T be a binary tree with λ levels. Then T has no more than 2λ – 1 nodes
c) Let T be a binary tree with N nodes. Then the number of levels is at least ceil(log (N + 1))
d) Let T be a binary tree with N nodes. Then the number of levels is at least floor(log (N + 1))
Answer: d
67. Construct a binary tree by using postorder and inorder sequences given below.
Inorder: N, M, P, O, Q
Postorder: N, P, Q, O, M

a)
b)

c)

d)
Answer: d
68. Construct a binary search tree by using postorder sequence given below.
Postorder: 2, 4, 3, 7, 9, 8, 5.
a)

b)

c)

d)
Answer: b
69. Construct a binary tree using inorder and level order traversal given below.
Inorder Traversal: 3, 4, 2, 1, 5, 8, 9
Level Order Traversal: 1, 4, 5, 9, 8, 2, 3

a)

b)

c)

d)
Answer: a
70. Which of the following is false about a binary search tree?
a) The left child is always lesser than its parent
b) The right child is always greater than its parent
c) The left and right sub-trees should also be binary search trees
d) In order sequence gives decreasing order of elements
Answer: d
71. How to search for a key in a binary search tree?
a)

public Tree search(Tree root, int key)


{
if( root == null || root.key == key )
{
return root;
}
if( root.key < key )
{
return search(root.right,key);
}
else
return search(root.left,key);
}
b)

public Tree search(Tree root, int key)


{
if( root == null || root.key == key )
{
return root;
}
if( root.key < key )
{
return search(root.left,key);
}
else
return search(root.right,key);
}
c)

public Tree search(Tree root, int key)


{
if( root == null)
{
return root;
}
if( root.key < key )
{
return search(root.right,key);
}
else
return search(root.left,key);
}
d)

public Tree search(Tree root, int key)


{
if( root == null)
{
return root;
}
if( root.key < key )
{
return search(root.right.right,key);
}
else
return search(root.left.left,key);
}
Answer: a
72. What is the speciality about the inorder traversal of a binary search tree?
a) It traverses in a non increasing order
b) It traverses in an increasing order
c) It traverses in a random fashion
d) It traverses based on priority of the node
Answer: b
73. How will you find the minimum element in a binary search tree?
a)

public void min(Tree root)


{
while(root.left() != null)
{
root = root.left();
}
System.out.println(root.data());
}
b)

public void min(Tree root)


{
while(root != null)
{
root = root.left();
}
System.out.println(root.data());
}
c)

public void min(Tree root)


{
while(root.right() != null)
{
root = root.right();
}
System.out.println(root.data());
}
d)

public void min(Tree root)


{
while(root != null)
{
root = root.right();
}
System.out.println(root.data());
}
Answer: a
74. How will you find the maximum element in a binary search tree?
a)

public void max(Tree root)


{
while(root.left() != null)
{
root = root.left();
}
System.out.println(root.data());
}
b)

public void max(Tree root)


{
while(root != null)
{
root = root.left();
}
System.out.println(root.data());
}
c)

public void max(Tree root)


{
while(root.right() != null)
{
root = root.right();
}
System.out.println(root.data());
}
d)

public void max(Tree root)


{
while(root != null)
{
root = root.right();
}
System.out.println(root.data());
}

Answer: c
75. What are the worst case and average case complexities of a binary search tree?
a) O(n), O(n)
b) O(logn), O(logn)
c) O(logn), O(n)
d) O(n), O(logn)
Answer: d
76. Construct a binary search tree with the below information.
The preorder traversal of a binary search tree 10, 4, 3, 5, 11, 12.

a)
b)

c)

d)
Answer: c
77. Which of the following statements for a simple graph is correct?
a) Every path is a trail
b) Every trail is a path
c) Every trail is a path as well as every path is a trail
d) Path and trail have no relation
Answer: a
78. n the given graph identify the cut vertices.

a) B and E
b) C and D
c) A and E
d) C and B
Answer: d
79. For the given graph(G), which of the following statements is true?

a) G is a complete graph
b) G is not a connected graph
c) The vertex connectivity of the graph is 2
d) The edge connectivity of the graph is 1
Answer: c
80. What is the number of edges present in a complete graph having n vertices?
a) (n*(n+1))/2
b) (n*(n-1))/2
c) n
d) Information given is insufficient
Answer: b
81. The given Graph is regular.

a) True
b) False
Answer: a
82. In a simple graph, the number of edges is equal to twice the sum of the degrees of the
vertices.
a) True
b) False
Answer: b
83. A connected planar graph having 6 vertices, 7 edges contains _____________ regions.
a) 15
b) 3
c) 1
d) 11
Answer: b
84. If a simple graph G, contains n vertices and m edges, the number of edges in the Graph
G'(Complement of G) is ___________
a) (n*n-n-2*m)/2
b) (n*n+n+2*m)/2
c) (n*n-n-2*m)/2
d) (n*n-n+2*m)/2
Answer: a
85. Which of the following properties does a simple graph not hold?
a) Must be connected
b) Must be unweighted
c) Must have no loops or multiple edges
d) Must have no multiple edges
Answer: a
86. What is the maximum number of edges in a bipartite graph having 10 vertices?
a) 24
b) 21
c) 25
d) 16
Answer: c
87. Which of the following is true?
a) A graph may contain no edges and many vertices
b) A graph may contain many edges and no vertices
c) A graph may contain no edges and no vertices
d) A graph may contain no vertices and many edges
Answer: b
88. For a given graph G having v vertices and e edges which is connected and has no cycles,
which of the following statements is true?
a) v=e
b) v = e+1
c) v + 1 = e
d) v = e-1
Answer: b
89. For which of the following combinations of the degrees of vertices would the connected
graph be eulerian?
a) 1,2,3
b) 2,3,4
c) 2,4,5
d) 1,3,5
90. A graph with all vertices having equal degree is known as a __________
a) Multi Graph
b) Regular Graph
c) Simple Graph
d) Complete Graph
Answer: b
91. Which of the following ways can be used to represent a graph?
a) Adjacency List and Adjacency Matrix
b) Incidence Matrix
c) Adjacency List, Adjacency Matrix as well as Incidence Matrix
d) No way to represent
Answer: c
92. The number of elements in the adjacency matrix of a graph having 7 vertices is
__________
a) 7
b) 14
c) 36
d) 49
Answer: d
93. What would be the number of zeros in the adjacency matrix of the given graph?

a) 10
b) 6
c) 16
d) 0
Answer: b
94. The time complexity to calculate the number of edges in a graph whose information in
stored in form of an adjacency matrix is ____________
a) O(V)
b) O(E2)
c) O(E)
d) O(V2)
Answer: d
95. For the adjacency matrix of a directed graph the row sum is the _________ degree and
the column sum is the ________ degree.
a) in, out
b) out, in
c) in, total
d) total, out
96. Space complexity for an adjacency list of an undirected graph having large values of V
(vertices) and E (edges) is ___________
a) O(E)
b) O(V*V)
c) O(E+V)
d) O(V)
Answer: c
97. Time complexity to find if there is an edge between 2 particular vertices is _________
a) O(V)
b) O(E)
c) O(1)
d) O(V+E)
Answer: a
98. Space complexity for an adjacency list of an undirected graph having large values of V
(vertices) and E (edges) is __________
a) O(V)
b) O(E*E)
c) O(E)
d) O(E+V)
Answer: c
99. A graph having an edge from each vertex to every other vertex is called a ___________
a) Tightly Connected
b) Strongly Connected
c) Weakly Connected
d) Loosely Connected
Answer: a
100. What is the number of unlabeled simple directed graph that can be made with 1 or 2
vertices?
a) 2
b) 4
c) 5
d) 9
Answer: b
100 MCQ – UNIT 3
Arrays and its representations – Stacks and Queues – Linked lists – Linked list-based implementation
of Stacks and Queues – Evaluation of Expressions – Linked list based polynomial addition.

1. Which of these best describes an array?


a) A data structure that shows a hierarchical behaviour
b) Container of objects of similar types
c) Arrays are immutable once initialised
d) Array is not a data structure

Answer: b
2. 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);
Answer: c
3. How do you instantiate an array in Java?
a) int arr[] = new int(3);
b) int arr[];
c) int arr[] = new int[3];
d) int arr() = new int(3);
Answer: c
4. Which of the following is a correct way to declare a multidimensional array in Java?
a) int[] arr;
b) int arr[[]];
c) int[][]arr;
d) int[[]] arr;
Answer: c
5. What is the output of the following piece of code?

public class array


{
public static void main(String args[])
{
int []arr = {1,2,3,4,5};
System.out.println(arr[2]);
System.out.println(arr[4]);
}
}

a) 3 and 5
b) 5 and 3
c) 2 and 4
d) 4 and 2

Answer: a
6. What is the output of the following piece of code?

public class array


{
public static void main(String args[])
{
int []arr = {1,2,3,4,5};
System.out.println(arr[5]);
}
}
a) 4
b) 5
c) ArrayIndexOutOfBoundsException
d) InavlidInputException

Answer: c
7. When does the ArrayIndexOutOfBoundsException occur?
a) Compile-time
b) Run-time
c) Not an error
d) Not an exception at all
Answer: b
8. Which of the following concepts make extensive use of arrays?
a) Binary trees
b) Scheduling of processes
c) Caching
d) Spatial locality
Answer: d
9. What are the advantages of arrays?
a) Objects of mixed data types can be stored
b) Elements in an array cannot be sorted
c) Index of first element of an array is 1
d) Easier to store elements of same data type
Answer: d
10. What are the disadvantages of arrays?
a) Data structure like queue or stack cannot be implemented
b) There are chances of wastage of memory space if elements inserted in an array are
lesser than the allocated size
c) Index value of an array can be negative
d) Elements are sequentially accessed
Answer: b
11.Assuming int is of 4bytes, what is the size of int arr[15];?
a) 15
b) 19
c) 11
d) 60
Answer: d
12. In general, the index of the first element in an array is __________
a) 0
b) -1
c) 2
d) 1
Answer: a
13. Elements in an array are accessed _____________
a) randomly
b) sequentially
c) exponentially
d) logarithmically
Answer: a
14. 1. Process of inserting an element in stack is called ____________
a) Create
b) Push
c) Evaluation
d) Pop
Answer: b
15. Process of removing an element from stack is called __________
a) Create
b) Push
c) Evaluation
d) Pop
Answer: d
16. In a stack, if a user tries to remove an element from empty stack it is called
_________
a) Underflow
b) Empty collection
c) Overflow
d) Garbage Collection
Answer: a
17. Pushing an element into stack already having five elements and stack size of 5, then
stack becomes
a) Overflow
b) Crash
c) Underflow
d) User flow
Answer: a
18. Entries in a stack are “ordered”. What is the meaning of this statement?
a) A collection of stacks is sortable
b) Stack entries may be compared with the ‘<‘ operation
c) The entries are stored in a linked list
d) There is a Sequential entry that is one by one
Answer: d
19. Which of the following is not the application of stack?
a) A parentheses balancing program
b) Tracking of local variables at run time
c) Compiler Syntax Analyzer
d) Data Transfer between two asynchronous process
Answer: d
20. Consider the usual algorithm for determining whether a sequence of parentheses is
balanced.
The maximum number of parentheses that appear on the stack AT ANY ONE TIME
when the algorithm analyzes: (()(())(())) are:
a) 1
b) 2
c) 3
d) 4 or more
Answer: c
21. Consider the usual algorithm for determining whether a sequence of parentheses is
balanced.
Suppose that you run the algorithm on a sequence that contains 2 left parentheses and
3 right parentheses (in some order).
The maximum number of parentheses that appear on the stack AT ANY ONE TIME
during the computation?
a) 1
b) 2
c) 3
d) 4 or more
Answer: b
22. What is the value of the postfix expression 6 3 2 4 + – *?
a) 1
b) 40
c) 74
d) -18
Answer: d
23. Here is an infix expression: 4 + 3*(6*3-12). Suppose that we are using the usual
stack algorithm to convert the expression from infix to postfix notation.
The maximum number of symbols that will appear on the stack AT ONE TIME during the
conversion of this expression?
a) 1
b) 2
c) 3
d) 4
Answer: d
24. The postfix form of the expression (A+ B)*(C*D- E)*F / G is?
a) AB+ CD*E – FG /**
b) AB + CD* E – F **G /
c) AB + CD* E – *F *G /
d) AB + CDE * – * F *G /
Answer: c
25. The data structure required to check whether an expression contains balanced
parenthesis is?
a) Stack
b) Queue
c) Array
d) Tree
Answer: a
26. What data structure would you mostly likely see in a non recursive implementation
of a recursive algorithm?
a) Linked List
b) Stack
c) Queue
d) Tree
Answer: b
27. The process of accessing data stored in a serial access memory is similar to
manipulating data on a ________
a) Heap
b) Binary Tree
c) Array
d) Stack
Answer: d
28. The postfix form of A*B+C/D is?
a) *AB/CD+
b) AB*CD/+
c) A*BC+/D
d) ABCD+/*
Answer: b
29. Which data structure is needed to convert infix notation to postfix notation?
a) Branch
b) Tree
c) Queue
d) Stack
Answer: d
30. The prefix form of A-B/ (C * D ^ E) is?
a) -/*^ACBDE
b) -ABCD*^DE
c) -A/B*C^DE
d) -A/BC*^DE
Answer: c
31. What is the result of the following operation?
Top (Push (S, X))
a) X
b) X+S
c) S
d) XS
Answer: a
32. The prefix form of an infix expression (p + q) – (r * t) is?
a) + pq – *rt
b) – +pqr * t
c) – +pq * rt
d) – + * pqrt
Answer: c
33. Which data structure is used for implementing recursion?
a) Queue
b) Stack
c) Array
d) List
Answer: b
34. The result of evaluating the postfix expression 5, 4, 6, +, *, 4, 9, 3, /, +, * is?
a) 600
b) 350
c) 650
d) 588
Answer: b
35. Convert the following infix expressions into its equivalent postfix expressions
(A + B ⋀D)/(E – F)+G
a) (A B D ⋀ + E F – / G +)
b) (A B D +⋀ E F – / G +)
c) (A B D ⋀ + E F/- G +)
d) (A B D E F + ⋀ / – G +)
Answer: a
36. Convert the following Infix expression to Postfix form using a stack
x + y * z + (p * q + r) * s, Follow usual precedence rule and assume that the expression
is legal.
a) xyz*+pq*r+s*+
b) xyz*+pq*r+s+*
c) xyz+*pq*r+s*+
d) xyzp+**qr+s*+
Answer: a
37. Which of the following statement(s) about stack data structure is/are NOT correct?
a) Linked List are used for implementing Stacks
b) Top of the Stack always contain the new node
c) Stack is the FIFO data structure
d) Null link is present in the last node at the bottom of the stack
Answer: c
38. Consider the following operation performed on a stack of size 5.
Push(1);
Pop();
Push(2);
Push(3);
Pop();
Push(4);
Pop();
Pop();
Push(5);
After the completion of all operation, the number of elements present in stack are
a) 1
b) 2
c) 3
d) 4
Answer: a
39. Which of the following is not an inherent application of stack?
a) Reversing a string
b) Evaluation of postfix expression
c) Implementation of recursion
d) Job scheduling
Answer: d
40. The type of expression in which operator succeeds its operands is?
a) Infix Expression
b) Prefix Expression
c) Postfix Expression
d) Both Prefix and Postfix Expressions
Answer: c
41. Assume that the operators +,-, X are left associative and ^ is right associative.
The order of precedence (from highest to lowest) is ^, X, +, -. The postfix expression for
the infix expression a + b X c – d ^ e ^ f is
a) abc X+ def ^^ –
b) abc X+ de^f^ –
c) ab+c Xd – e ^f^
d) -+aXbc^ ^def
Answer: b
42. If the elements “A”, “B”, “C” and “D” are placed in a stack and are deleted one at a
time, what is the order of removal?
a) ABCD
b) DCBA
c) DCAB
d) ABDC
Answer: b
43. 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
Answer: a
44. The data structure required for Breadth First Traversal on a graph is?
a) Stack
b) Array
c) Queue
d) Tree
Answer: c
45. A queue follows __________
a) FIFO (First In First Out) principle
b) LIFO (Last In First Out) principle
c) Ordered array
d) Linear tree
Answer: a
46. Circular Queue is also known as ________
a) Ring Buffer
b) Square Buffer
c) Rectangle Buffer
d) Curve Buffer
Answer: a
47. 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
Answer: a
48. 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
Answer: c
49. 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
Answer: a
50. 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
Answer: c
51. Which of the following is not the type of queue?
a) Ordinary queue
b) Single ended queue
c) Circular queue
d) Priority queue
Answer: b
52. A linear collection of data elements where the linear node is given by means of
pointer is called?
a) Linked list
b) Node list
c) Primitive list
d) Unordered list
Answer: a
53. Consider an implementation of unsorted singly linked list. Suppose it has its
representation with a head pointer only.
Given the representation, which of the following operation can be implemented in O(1)
time?
i) Insertion at the front of the linked list
ii) Insertion at the end of the linked list
iii) Deletion of the front node of the linked list
iv) Deletion of the last node of the linked list
a) I and II
b) I and III
c) I, II and III
d) I, II and IV
Answer: b
54. In linked list each node contain minimum of two fields. One field is data field to store
the data second field is?
a) Pointer to character
b) Pointer to integer
c) Pointer to node
d) Node
Answer: c
55. What would be the asymptotic time complexity to add a node at the end of singly
linked list, if the pointer is initially pointing to the head of the list?
a) O(1)
b) O(n)
c) θ(n)
d) θ(1)
Answer: c
56. What would be the asymptotic time complexity to insert an element at the front of the
linked list (head is known)?
a) O(1)
b) O(n)
c) O(n2)
d) O(n3)
Answer: a
57. What would be the asymptotic time complexity to find an element in the linked list?
a) O(1)
b) O(n)
c) O(n2)
d) O(n4)
Answer: b
58. What would be the asymptotic time complexity to insert an element at the second
position in the linked list?
a) O(1)
b) O(n)
c) O(n2)
d) O(n3)
Answer: a
59. The concatenation of two list can performed in O(1) time. Which of the following
variation of linked list can be used?
a) Singly linked list
b) Doubly linked list
c) Circular doubly linked list
d) Array implementation of list
Answer: c
60. Consider the following definition in c programming language

struct node
{
int data;
struct node * next;
}
typedef struct node NODE;
NODE *ptr;
Which of the following c code is used to create new node?
a) ptr = (NODE*)malloc(sizeof(NODE));
b) ptr = (NODE*)malloc(NODE);
c) ptr = (NODE*)malloc(sizeof(NODE*));
d) ptr = (NODE)malloc(sizeof(NODE));

Answer: a
61. Which of the following is not a disadvantage to the usage of array?
a) Fixed size
b) There are chances of wastage of memory space if elements inserted in an array are
lesser than the allocated size
c) Insertion based on position
d) Accessing elements at specified positions
Answer: d
62. What is the time complexity of inserting at the end in dynamic arrays?
a) O(1)
b) O(n)
c) O(logn)
d) Either O(1) or O(n)
Answer: d
63. What is the time complexity to count the number of elements in the linked list?
a) O(1)
b) O(n)
c) O(logn)
d) O(n2)
Answer: b
64. Which of the following performs deletion of the last element in the list? Given below
is the Node class.

class Node
{
protected Node next;
protected Object ele;
Node(Object e,Node n)
{
ele = e;
next = n;
}
public void setNext(Node n)
{
next = n;
}
public void setEle(Object e)
{
ele = e;
}
public Node getNext()
{
return next;
}
public Object getEle()
{
return ele;
}
}
class SLL
{
Node head;
int size;
SLL()
{
size = 0;
}
}
a)

public Node removeLast()


{
if(size == 0)
return null;
Node cur;
Node temp;
cur = head;
while(cur.getNext() != null)
{
temp = cur;
cur = cur.getNext();
}
temp.setNext(null);
size--;
return cur;
}
b)

public void removeLast()


{
if(size == 0)
return null;
Node cur;
Node temp;
cur = head;
while(cur != null)
{
temp = cur;
cur = cur.getNext();
}
temp.setNext(null);
return cur;
}
c)

public void removeLast()


{
if(size == 0)
return null;
Node cur;
Node temp;
cur = head;
while(cur != null)
{
cur = cur.getNext();
temp = cur;
}
temp.setNext(null);
return cur;
}
d)

public void removeLast()


{
if(size == 0)
return null;
Node cur;
Node temp;
cur = head;
while(cur.getNext() != null)
{
cur = cur.getNext();
temp = cur;
}
temp.setNext(null);
return cur;
}
Answer: a
65. What is the functionality of the following code?
public void function(Node node)
{
if(size == 0)
head = node;
else
{
Node temp,cur;
for(cur = head; (temp = cur.getNext())!=null; cur = temp);
cur.setNext(node);
}
size++;
}
a) Inserting a node at the beginning of the list
b) Deleting a node at the beginning of the list
c) Inserting a node at the end of the list
d) Deleting a node at the end of the list

Answer: c
66. What is the space complexity for deleting a linked list?
a) O(1)
b) O(n)
c) Either O(1) or O(n)
d) O(logn)
Answer: a
67. How would you delete a node in the singly linked list? The position to be deleted is
given.
a)

public void delete(int pos)


{
if(pos < 0)
pos = 0;
if(pos > size)
pos = size;
if( size == 0)
return;
if(pos == 0)
head = head.getNext();
else
{
Node temp = head;
for(int i=1; i<pos; i++)
{
temp = temp.getNext();
}
temp.setNext(temp.getNext().getNext());
}
size--;
}
b)

public void delete(int pos)


{
if(pos < 0)
pos = 0;
if(pos > size)
pos = size;
if( size == 0)
return;
if(pos == 0)
head = head.getNext();
else
{
Node temp = head;
for(int i=1; i<pos; i++)
{
temp = temp.getNext();
}
temp.setNext(temp.getNext());
}
size--;
}
c)

public void delete(int pos)


{
if(pos < 0)
pos = 0;
if(pos > size)
pos = size;
if( size == 0)
return;
if(pos == 0)
head = head.getNext();
else
{
Node temp = head;
for(int i=1; i<pos; i++)
{
temp = temp.getNext().getNext();
}
temp.setNext(temp.getNext().getNext());
}
size--;
}
d)

public void delete(int pos)


{
if(pos < 0)
pos = 0;
if(pos > size)
pos = size;
if( size == 0)
return;
if(pos == 0)
head = head.getNext();
else
{
Node temp = head;
for(int i=0; i<pos; i++)
{
temp = temp.getNext();
}
temp.setNext(temp.getNext().getNext());
}
size--;
}
Answer: a
68. Which of these is not an application of linked list?
a) To implement file systems
b) For separate chaining in hash-tables
c) To implement non-binary trees
d) Random Access of elements
Answer: d
69. Which of the following piece of code has the functionality of counting the number of
elements in the list?
a)

public int length(Node head)


{
int size = 0;
Node cur = head;
while(cur!=null)
{
size++;
cur = cur.getNext();
}
return size;
}
b)

public int length(Node head)


{
int size = 0;
Node cur = head;
while(cur!=null)
{
cur = cur.getNext();
size++;
}
return size;
}
c)

public int length(Node head)


{
int size = 0;
Node cur = head;
while(cur!=null)
{
size++;
cur = cur.getNext();
}
}
d)

public int length(Node head)


{
int size = 0;
Node cur = head;
while(cur!=null)
{
size++;
cur = cur.getNext().getNext();
}
return size;
}
Answer: a
70. How do you insert an element at the beginning of the list?
a)
public void insertBegin(Node node)
{
node.setNext(head);
head = node;
size++;
}

b)

public void insertBegin(Node node)


{
head = node;
node.setNext(head);
size++;
}

c)

public void insertBegin(Node node)


{
Node temp = head.getNext()
node.setNext(temp);
head = node;
size++;
}

d)

public void insertBegin(Node node)


{
Node temp = head.getNext()
node.setNext(temp);
node = head;
size++;
}

Answer: a
71. What is the functionality of the following piece of code?
public int function(int data)
{
Node temp = head;
int var = 0;
while(temp != null)
{
if(temp.getData() == data)
{
return var;
}
var = var+1;
temp = temp.getNext();
}
return Integer.MIN_VALUE;
}
a) Find and delete a given element in the list
b) Find and return the given element in the list
c) Find and return the position of the given element in the list
d) Find and insert a new element in the list

Answer: c
72. Which of the following is false about a doubly linked list?
a) We can navigate in both the directions
b) It requires more space than a singly linked list
c) The insertion and deletion of a node take a bit longer
d) Implementing a doubly linked list is easier than singly linked list
Answer: d
73. iven the Node class implementation, select one of the following that correctly inserts
a node at the tail of the list.

public class Node


{
protected int data;
protected Node prev;
protected Node next;
public Node(int data)
{
this.data = data;
prev = null;
next = null;
}
public Node(int data, Node prev, Node next)
{
this.data = data;
this.prev = prev;
this.next = next;
}
public int getData()
{
return data;
}
public void setData(int data)
{
this.data = data;
}
public Node getPrev()
{
return prev;
}
public void setPrev(Node prev)
{
this.prev = prev;
}
public Node getNext
{
return next;
}
public void setNext(Node next)
{
this.next = next;
}
}
public class DLL
{
protected Node head;
protected Node tail;
int length;
public DLL()
{
head = new Node(Integer.MIN_VALUE,null,null);
tail = new Node(Integer.MIN_VALUE,null,null);
head.setNext(tail);
length = 0;
}
}
a)

public void insertRear(int data)


{
Node node = new Node(data,tail.getPrev(),tail);
node.getPrev().setNext(node);
tail.setPrev(node);
length++;
}
b)

public void insertRear(int data)


{
Node node = new Node(data,tail.getPrev(),tail);
node.getPrev().getPrev().setNext(node);
tail.setPrev(node);
length++;
}
c)

public void insertRear(int data)


{
Node node = new Node(data,tail.getPrev(),tail);
node.getPrev().setNext(tail);
tail.setPrev(node);
length++;
}
d)

public void insertRear(int data)


{
Node node = new Node(data,head,tail);
node.getPrev().setNext(node);
tail.setPrev(node);
length++;
}
Answer: a
74. What is a memory efficient double linked list?
a) Each node has only one pointer to traverse the list back and forth
b) The list has breakpoints for faster traversal
c) An auxiliary singly linked list acts as a helper list to traverse through the doubly linked
list
d) A doubly linked list that uses bitwise AND operator for storing addresses
Answer: a
75. Which of the following piece of code removes the node from a given position?
a)

public void remove(int pos)


{
if(pos<0 || pos>=size)
{
System.out.println("Invalid position");
return;
}
else
{
if(head == null)
return;
if(pos == 0)
{
head = head.getNext();
if(head == null)
tail = null;
}
else
{
Node temp = head;
for(int i=1; i<position; i++)
temp = temp.getNext();
}
temp.getNext().setPrev(temp.getPrev());
temp.getPrev().setNext(temp.getNext());
}
size--;
}
b)

public void remove(int pos)


{
if(pos<0 || pos>=size)
{
System.out.println("Invalid position");
return;
}
else
{
if(head == null)
return;
if(pos == 0)
{
head = head.getNext();
if(head == null)
tail = null;
}
else
{
Node temp = head;
for(int i=1; i<position; i++)
temp = temp.getNext();
}
temp.getNext().setPrev(temp.getNext());
temp.getPrev().setNext(temp.getPrev());
}
size--;
}
c)

public void remove(int pos)


{
if(pos<0 || pos>=size)
{
System.out.println("Invalid position");
return;
}
else
{
if(head == null)
return;
if(pos == 0)
{
head = head.getNext();
if(head == null)
tail = null;
}
else
{
Node temp = head;
for(int i=1; i<position; i++)
temp = temp.getNext().getNext();
}
temp.getNext().setPrev(temp.getPrev());
temp.getPrev().setNext(temp.getNext());
}
size--;
}
d)

public void remove(int pos)


{
if(pos<0 || pos>=size)
{
System.out.println("Invalid position");
return;
}
else
{
if(head == null)
return;
if(pos == 0)
{
head = head.getNext();
if(head == null)
tail = null;
}
else
{
Node temp = head;
for(int i=1; i<position; i++)
temp = temp.getNext().getNext();
}
temp.getNext().setPrev(temp.getNext());
temp.getPrev().setNext(temp.getPrev());
}
size--;
}
Answer: a
76. How do you calculate the pointer difference in a memory efficient double linked list?
a) head xor tail
b) pointer to previous node xor pointer to next node
c) pointer to previous node – pointer to next node
d) pointer to next node – pointer to previous node
Answer: b
77. What is the worst case time complexity of inserting a node in a doubly linked list?
a) O(nlogn)
b) O(logn)
c) O(n)
d) O(1)
Answer: c
78. How do you insert a node at the beginning of the list?
a)

public class insertFront(int data)


{
Node node = new Node(data, head, head.getNext());
node.getNext().setPrev(node);
head.setNext(node);
size++;
}
b)

public class insertFront(int data)


{
Node node = new Node(data, head, head);
node.getNext().setPrev(node);
head.setNext(node);
size++;
}
c)

public class insertFront(int data)


{
Node node = new Node(data, head, head.getNext());
node.getNext().setPrev(head);
head.setNext(node);
size++;
}
d)

public class insertFront(int data)


{
Node node = new Node(data, head, head.getNext());
node.getNext().setPrev(node);
head.setNext(node.getNext());
size++;
}
Answer: a
79. Consider the following doubly linked list: head-1-2-3-4-5-tail
What will be the list after performing the given sequence of operations?

Node temp = new Node(6,head,head.getNext());


Node temp1 = new Node(0,tail.getPrev(),tail);
head.setNext(temp);
temp.getNext().setPrev(temp);
tail.setPrev(temp1);
temp1.getPrev().setNext(temp1);
a) head-0-1-2-3-4-5-6-tail
b) head-1-2-3-4-5-6-tail
c) head-6-1-2-3-4-5-0-tail
d) head-0-1-2-3-4-5-tail

Answer: c
80. What is the functionality of the following piece of code?

public int function()


{
Node temp = tail.getPrev();
tail.setPrev(temp.getPrev());
temp.getPrev().setNext(tail);
size--;
return temp.getItem();
}
a) Return the element at the tail of the list but do not remove it
b) Return the element at the tail of the list and remove it from the list
c) Return the last but one element from the list but do not remove it
d) Return the last but one element at the tail of the list and remove it from the list

Answer: b
81.Consider the following doubly linked list: head-1-2-3-4-5-tail
What will be the list after performing the given sequence of operations?

Node temp = new Node(6,head,head.getNext());


head.setNext(temp);
temp.getNext().setPrev(temp);
Node temp1 = tail.getPrev();
tail.setPrev(temp1.getPrev());
temp1.getPrev().setNext(tail);
a) head-6-1-2-3-4-5-tail
b) head-6-1-2-3-4-tail
c) head-1-2-3-4-5-6-tail
d) head-1-2-3-4-5-tail
Answer: b

82. What differentiates a circular linked list from a normal linked list?
a) You cannot have the ‘next’ pointer point to null in a circular linked list
b) It is faster to traverse the circular linked list
c) You may or may not have the ‘next’ pointer point to null in a circular linked list
d) Head node is known in circular linked list
Answer: c
83. What is the time complexity of searching for an element in a circular linked list?
a) O(n)
b) O(nlogn)
c) O(1)
d) O(n2)
Answer: a
84. Which of the following application makes use of a circular linked list?
a) Undo operation in a text editor
b) Recursive function calls
c) Allocating CPU to resources
d) Implement Hash Tables
Answer: c
85. Which of the following real world scenarios would you associate with a stack data
structure?
a) piling up of chairs one above the other
b) people standing in a line to be serviced at a counter
c) offer services based on the priority of the customer
d) tatkal Ticket Booking in IRCTC
Answer: a
86. hat does the following function check for? (all necessary headers to be included and
function is called from main)

#define MAX 10

typedef struct stack


{
int top;
int item[MAX];
}stack;

int function(stack *s)


{
if(s->top == -1)
return 1;
else return 0;
}
a) full stack
b) invalid index
c) empty stack
d) infinite stack

Answer: c
87. 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
Answer: c
88. 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)
Answer: a
89. Which of the following array position will be occupied by a new element being
pushed for a stack of size N elements(capacity of stack > N).
a) S[N-1]
b) S[N]
c) S[1]
d) S[0]
Answer: b
90. What happens when you pop from an empty stack while implementing using the
Stack ADT in Java?
a) Undefined error
b) Compiler displays a warning
c) EmptyStackException is thrown
d) NoStackException is thrown
Answer: c
91.What is the best case time complexity of deleting a node in Singly Linked list?
a) O (n)
b) O (n2)
c) O (nlogn)
d) O (1)
Answer: d
92. Which of the following statements are not correct with respect to Singly Linked
List(SLL) and Doubly Linked List(DLL)?
a) Complexity of Insertion and Deletion at known position is O(n) in SLL and O(1) in DLL
b) SLL uses lesser memory per node than DLL
c) DLL has more searching power than SLL
d) Number of node fields in SLL is more than DLL
Answer: d
93. What does the following function do?
public Object some_func()throws emptyStackException
{
if(isEmpty())
throw new emptyStackException("underflow");
return first.getEle();
}

a) pop
b) delete the top-of-the-stack element
c) retrieve the top-of-the-stack element
d) push operation

Answer: c

94. What is the functionality of the following piece of code?

public void display()


{
if(size == 0)
System.out.println("underflow");
else
{
Node current = first;
while(current != null)
{
System.out.println(current.getEle());
current = current.getNext();
}
}
}
a) reverse the list
b) display the list
c) display the list excluding top-of-the-stack-element
d) reverse the list excluding top-of-the-stack-element

Answer: b

95. What does ‘stack overflow’ refer to?


a) accessing item from an undefined stack
b) adding items to a full stack
c) removing items from an empty stack
d) index out of bounds exception

Answer: b

96. Which of the following data structures can be used for parentheses matching?
a) n-ary tree
b) queue
c) priority queue
d) stack

Answer: d

97. Minimum number of queues to implement stack is ___________


a) 3
b) 4
c) 1
d) 2

Answer: c

98. In linked list implementation of queue, if only front pointer is maintained, which of
the following operation take worst case linear time?
a) Insertion
b) Deletion
c) To empty a queue
d) Both Insertion and To empty a queue

Answer: d

99. In linked list implementation of a queue, where does a new element be inserted?
a) At the head of link list
b) At the centre position in the link list
c) At the tail of the link list
d) At any position in the linked list

Answer: c

100. In linked list implementation of a queue, front and rear pointers are tracked. Which
of these pointers will change during an insertion into a NONEMPTY queue?
a) Only front pointer
b) Only rear pointer
c) Both front and rear pointer
d) No pointer will be changed

Answer: b
100 MCQ - UNIT 2
1.What will be the output of the following C code?

1. #include <stdio.h>
2. int main()
3. {
4. void foo();
5. printf("1 ");
6. foo();
7. }
8. void foo()
9. {
10. printf("2 ");
11. }
a) 1 2
b) Compile time error
c) 1 2 1 2
d) Depends on the compiler
Answer: a
2. What will be the output of the following C code?

1. #include <stdio.h>
2. int main()
3. {
4. void foo(), f();
5. f();
6. }
7. void foo()
8. {
9. printf("2 ");
10. }
11. void f()
12. {
13. printf("1 ");
14. foo();
15. }
a) Compile time error as foo is local to main
b) 1 2
c) 2 1
d) Compile time error due to declaration of functions inside main

Answer: b
3. What will be the output of the following C code?
1. #include <stdio.h>
2. int main()
3. {
4. void foo();
5. void f()
6. {
7. foo();
8. }
9. f();
10. }
11. void foo()
12. {
13. printf("2 ");
14. }
a) 2 2
b) 2
c) Compile time error
d) Depends on the compiler

Answer: d

4. What will be the output of the following C code?

1. #include <stdio.h>
2. void foo();
3. int main()
4. {
5. void foo();
6. foo();
7. return 0;
8. }
9. void foo()
10. {
11. printf("2 ");
12. }
a) Compile time error
b) 2
c) Depends on the compiler
d) Depends on the standard

Answer: b

5. What will be the output of the following C code?

1. #include <stdio.h>
2. void foo();
3. int main()
4. {
5. void foo(int);
6. foo(1);
7. return 0;
8. }
9. void foo(int i)
10. {
11. printf("2 ");
12. }
a) 2
b) Compile time error
c) Depends on the compiler
d) Depends on the standard

Answer: a

6. What will be the output of the following C code?

1. #include <stdio.h>
2. void foo();
3. int main()
4. {
5. void foo(int);
6. foo();
7. return 0;
8. }
9. void foo()
10. {
11. printf("2 ");
12. }
a) 2
b) Compile time error
c) Depends on the compiler
d) Depends on the standard

Answer: b

7. What will be the output of the following C code?

1. #include <stdio.h>
2. void m()
3. {
4. printf("hi");
5. }
6. void main()
7. {
8. m();
9. }
a) hi
b) Run time error
c) Nothing
d) Varies

Answer: a

8. What will be the output of the following C code?

1. #include <stdio.h>
2. void m();
3. void n()
4. {
5. m();
6. }
7. void main()
8. {
9. void m()
10. {
11. printf("hi");
12. }
13. }
a) hi
b) Compile time error
c) Nothing
d) Varies

Answer: b

9. What will be the output of the following C code?

1. #include <stdio.h>
2. void main()
3. {
4. m();
5. void m()
6. {
7. printf("hi");
8. }
9. }
a) hi
b) Compile time error
c) Nothing
d) Varies
Answer: b

10. What will be the output of the following C code?

1. #include <stdio.h>
2. void main()
3. {
4. m();
5. }
6. void m()
7. {
8. printf("hi");
9. m();
10. }
a) Compile time error
b) hi
c) Infinite hi
d) Nothing

11. What will be the output of the following C code?

1. #include <stdio.h>
2. void main()
3. {
4. static int x = 3;
5. x++;
6. if (x <= 5)
7. {
8. printf("hi");
9. main();
10. }
11. }
a) Run time error
b) hi
c) Infinite hi
d) hi hi

Answer: d

12. Which of the following is a correct format for declaration of function?


a) return-type function-name(argument type);
b) return-type function-name(argument type){}
c) return-type (argument type)function-name;
d) all of the mentioned
Answer: a
13. Which of the following function declaration is illegal?
a) int 1bhk(int);
b) int 1bhk(int a);
c) int 2bhk(int*, int []);
d) all of the mentioned

Answer: d

14. Which function definition will run correctly?


a)

int sum(int a, int b)


return (a + b);
b)

int sum(int a, int b)


{return (a + b);}
c)

int sum(a, b)
return (a + b);
d) none of the mentioned

Answer: b

15. Can we use a function as a parameter of another function? [Eg: void wow(int func())].
a) Yes, and we can use the function value conveniently
b) Yes, but we call the function again to get the value, not as convenient as in using variable
c) No, C does not support it
d) This case is compiler dependent

Answer: c

16. The value obtained in the function is given back to main by using ________ keyword.
a) return
b) static
c) new
d) volatile

Answer: a

17. What is the return-type of the function sqrt()?


a) int
b) float
c) double
d) depends on the data type of the parameter

Answer: c
18. Which of the following function declaration is illegal?
a)

double func();
int main(){}
double func(){}
b)

double func(){};
int main(){}
c)

int main()
{
double func();
}
double func(){//statements}
d) None of the mentioned

Answer: d

19. What will be the output of the following C code having void return-type function?

1. #include <stdio.h>
2. void foo()
3. {
4. return 1;
5. }
6. void main()
7. {
8. int x = 0;
9. x = foo();
10. printf("%d", x);
11. }
a) 1
b) 0
c) Runtime error
d) Compile time error

Answer: d

20. What will be the data type returned for the following C function?

1. #include <stdio.h>
2. int func()
3. {
4. return (double)(char)5.0;
5. }
a) char
b) int
c) double
d) multiple type-casting in return is illegal

Answer: b

21. What is the problem in the following C declarations?

int func(int);
double func(int);
int func(float);
a) A function with same name cannot have different signatures
b) A function with same name cannot have different return types
c) A function with same name cannot have different number of parameters
d) All of the mentioned

Answer: d

22. What will be the output of the following C code?

1. #include <stdio.h>
2. void main()
3. {
4. int k = m();
5. printf("%d", k);
6. }
7. void m()
8. {
9. printf("hello");
10. }
a) hello 5
b) Error
c) Nothing
d) Junk value

Answer: a

23. What will be the output of the following C code?

1. #include <stdio.h>
2. int *m()
3. {
4. int *p = 5;
5. return p;
6. }
7. void main()
8. {
9. int *k = m();
10. printf("%d", k);
11. }
a) 5
b) Junk value
c) 0
d) Error

Answer: a

24. What will be the output of the following C code?

1. #include <stdio.h>
2. int *m();
3. void main()
4. {
5. int *k = m();
6. printf("hello ");
7. printf("%d", k[0]);
8. }
9. int *m()
10. {
11. int a[2] = {5, 8};
12. return a;
13. }
a) hello 5 8
b) hello 5
c) hello followed by garbage value
d) Compilation error

Answer: c

25. What will be the output of the following C code?

1. #include <stdio.h>
2. int *m();
3. void main()
4. {
5. int k = m();
6. printf("%d", k);
7. }
8. int *m()
9. {
10. int a[2] = {5, 8};
11. return a;
12. }
a) 5
b) 8
c) Nothing
d) Varies

Answer: d

26. What will be the output of the following C code?

1. #include <stdio.h>
2. void m(int k)
3. {
4. printf("hi");
5. }
6. void m(double k)
7. {
8. printf("hello");
9. }
10. void main()
11. {
12. m(3);
13. }
a) hi
b) hello
c) Compile time error
d) Nothing

Answer: c

27. What is the default return type if it is not specified in function definition?
a) void
b) int
c) double
d) short int

Answer: b

28. What will be the output of the following C code?

1. #include <stdio.h>
2. int foo();
3. int main()
4. {
5. int i = foo();
6. }
7. foo()
8. {
9. printf("2 ");
10. return 2;
11. }
a) 2
b) Compile time error
c) Depends on the compiler
d) Depends on the standard

Answer: a

29. What will be the output of the following C code?

1. #include <stdio.h>
2. double foo();
3. int main()
4. {
5. foo();
6. return 0;
7. }
8. foo()
9. {
10. printf("2 ");
11. return 2;
12. }
a) 2
b) Compile time error
c) Depends on the compiler
d) Depends on the standard

Answer: b

30. Functions can return structure in C?


a) True
b) False
c) Depends on the compiler
d) Depends on the standard

Answer: a

31. Functions can return enumeration constants in C?


a) true
b) false
c) depends on the compiler
d) depends on the standard

Answer: a

32. What will be the output of the following C code?

1. #include <stdio.h>
2. enum m{JAN, FEB, MAR};
3. enum m foo();
4. int main()
5. {
6. enum m i = foo();
7. printf("%d\n", i);
8. }
9. int foo()
10. {
11. return JAN;
12. }
a) Compile time error
b) 0
c) Depends on the compiler
d) Depends on the standard

Answer: a

33. What will be the output of the following C code?

1. #include <stdio.h>
2. void main()
3. {
4. m();
5. printf("%d", x);
6. }
7. int x;
8. void m()
9. {
10. x = 4;
11. }
a) 4
b) Compile time error
c) 0
d) Undefined

Answer: b

34. What will be the output of the following C code?


1. #include <stdio.h>
2. int x;
3. void main()
4. {
5. printf("%d", x);
6. }
a) Junk value
b) Run time error
c) 0
d) Undefined

Answer: c

35. What will be the output of the following C code?

1. #include <stdio.h>
2. int x = 5;
3. void main()
4. {
5. int x = 3;
6. printf("%d", x);
7. {
8. x = 4;
9. }
10. printf("%d", x);
11. }
a) Run time error
b) 3 3
c) 3 5
d) 3 4

Answer: d

36. What will be the output of the following C code?

1. #include <stdio.h>
2. int x = 5;
3. void main()
4. {
5. int x = 3;
6. printf("%d", x);
7. {
8. int x = 4;
9. }
10. printf("%d", x);
11. }
a) 3 3
b) 3 4
c) 3 5
d) Run time error

Answer: a

37. unctions in C are always _________


a) Internal
b) External
c) Both Internal and External
d) External and Internal are not valid terms for functions

Answer: b

38. Global variables are ____________


a) Internal
b) External
c) Both Internal and External
d) None of the mentioned

Answer: b

39. Which of the following is an external variable in the following C code?

1. #include <stdio.h>
2. int func (int a)
3. {
4. int b;
5. return b;
6. }
7. int main()
8. {
9. int c;
10. func (c);
11. }
12. int d;
a) a
b) b
c) c
d) d

Answer: d

40. What will be the output of the following C code?


1. #include <stdio.h>
2. int main()
3. {
4. printf("%d", d++);
5. }
6. int d = 10;
a) 9
b) 10
c) 11
d) Compile time error

Answer: d

41. What will be the output of the following C code?

1. #include <stdio.h>
2. double var = 8;
3. int main()
4. {
5. int var = 5;
6. printf("%d", var);
7. }
a) 5
b) 8
c) Compile time error due to wrong format identifier for double
d) Compile time error due to redeclaration of variable with same name

Answer: a

42. What will be the output of the following C code?

1. #include <stdio.h>
2. int main()
3. {
4. char *p = NULL;
5. char *q = 0;
6. if (p)
7. printf(" p ");
8. else
9. printf("nullp");
10. if (q)
11. printf("q\n");
12. else
13. printf(" nullq\n");
14. }
a) nullp nullq
b) Depends on the compiler
c) x nullq where x can be p or nullp depending on the value of NULL
d) p q

Answer: a

43. What will be the output of the following C code?

1. #include <stdio.h>
2. int main()
3. {
4. int i = 10;
5. void *p = &i;
6. printf("%d\n", (int)*p);
7. return 0;
8. }
a) Compile time error
b) Segmentation fault/runtime crash
c) 10
d) Undefined behaviou

Answer: a

44. What will be the output of the following C code?

1. #include <stdio.h>
2. int main()
3. {
4. int i = 10;
5. void *p = &i;
6. printf("%f\n", *(float*)p);
7. return 0;
8. }
a) Compile time error
b) Undefined behaviour
c) 10
d) 0.000000

Answer: d

45. What will be the output of the following C code?

1. #include <stdio.h>
2. int *f();
3. int main()
4. {
5. int *p = f();
6. printf("%d\n", *p);
7. }
8. int *f()
9. {
10. int *j = (int*)malloc(sizeof(int));
11. *j = 10;
12. return j;
13. }
a) 10
b) Compile time error
c) Segmentation fault/runtime crash since pointer to local variable is returned
d) Undefined behaviour

Answer: a

46. What will be the output of the following C code?

1. #include <stdio.h>
2. int *f();
3. int main()
4. {
5. int *p = f();
6. printf("%d\n", *p);
7. }
8. int *f()
9. {
10. int j = 10;
11. return &j;
12. }
a) 10
b) Compile time error
c) Segmentation fault/runtime crash
d) Undefined behaviour

Answer: a

47. omment on the following pointer declaration.

int *ptr, p;

a) ptr is a pointer to integer, p is not


b) ptr and p, both are pointers to integer
c) ptr is a pointer to integer, p may or may not be
d) ptr and p both are not pointers to integer

Answer: a
48. What will be the output of the following C code?

1. #include <stdio.h>
2. int main()
3. {
4. int *ptr, a = 10;
5. ptr = &a;
6. *ptr += 1;
7. printf("%d,%d/n", *ptr, a);
8. }
a) 10,10
b) 10,11
c) 11,10
d) 11,11

Answer: d

49. Comment on the following C statement.

const int *ptr;

a) You cannot change the value pointed by ptr


b) You cannot change the pointer ptr itself
c) You May or may not change the value pointed by ptr
d) You can change the pointer as well as the value pointed by it

Answer: a

50. Property which allows to produce different executable for different platforms in C is
called?
a) File inclusion
b) Selective inclusion
c) Conditional compilation
d) Recursive macros

Answer: c

51. What is #include <stdio.h>?


a) Preprocessor directive
b) Inclusion directive
c) File inclusion directive
d) None of the mentioned

Answer: a
52. C preprocessors can have compiler specific features.
a) True
b) False
c) Depends on the standard
d) Depends on the platform

Answer: a

53. What will be the output of the following C code?

1. #include <stdio.h>
2. #define foo(m, n) m * n = 10
3. int main()
4. {
5. printf("in main\n");
6. }
a) In main
b) Compilation error as lvalue is required for the expression m*n=10
c) Preprocessor error as lvalue is required for the expression m*n=10
d) None of the mentioned

Answer: a

54. C preprocessor is conceptually the first step during compilation.


a) True
b) False
c) Depends on the compiler
d) Depends on the standard

Answer: a

55. Preprocessor feature that supply line numbers and filenames to compiler is called?
a) Selective inclusion
b) macro substitution
c) Concatenation
d) Line control

Answer: d

56. #include <somefile.h> are _______ files and #include “somefile.h” ________ files.
a) Library, Library
b) Library, user-created header
c) User-created header, library
d) They can include all types of file

Answer: d
57. What is a preprocessor?
a) That processes its input data to produce output that is used as input to another program
b) That is nothing but a loader
c) That links various source files
d) All of the mentioned

Answer: a

58. What will be the output of the following C code?

1. #include <stdio.h>
2. void main()
3. {
4. int a[3] = {1, 2, 3};
5. int *p = a;
6. printf("%p\t%p", p, a);
7. }
a) Same address is printed
b) Different address is printed
c) Compile time error
d) Nothing

Answer: a

59. What will be the output of the following C code?

1. #include <stdio.h>
2. void main()
3. {
4. char *s = "hello";
5. char *p = s;
6. printf("%p\t%p", p, s);
7. }
a) Different address is printed
b) Same address is printed
c) Run time error
d) Nothing

Answer: b

60. What will be the output of the following C code?

1. #include <stdio.h>
2. void main()
3. {
4. char *s= "hello";
5. char *p = s;
6. printf("%c\t%c", p[0], s[1]);
7. }
a) Run time error
b) h h
c) h e
d) h l

Answer: c

61. 1. Which is an indirection operator among the following?


a) &
b) *
c) ->
d) .

Answer: b

62. Which of the following does not initialize ptr to null (assuming variable declaration of a
as int a=0;)?
a) int *ptr = &a;
b) int *ptr = &a – &a;
c) int *ptr = a – a;
d) All of the mentioned

Answer: a

63. What will be the output of the following C code?

1. #include <stdio.h>
2. int x = 0;
3. void main()
4. {
5. int *ptr = &x;
6. printf("%p\n", ptr);
7. x++;
8. printf("%p\n ", ptr);
9. }
a) Same address
b) Different address
c) Compile time error
d) Varies

Answer: a

64. What will be the output of the following C code?


1. #include <stdio.h>
2. int x = 0;
3. void main()
4. {
5. int *const ptr = &x;
6. printf("%p\n", ptr);
7. ptr++;
8. printf("%p\n ", ptr);
9. }
a) 0 1
b) Compile time error
c) 0xbfd605e8 0xbfd605ec
d) 0xbfd605e8 0xbfd605e8

Answer: b

65. . What will be the output of the following C code?

1. #include <stdio.h>
2. void main()
3. {
4. int x = 0;
5. int *ptr = &5;
6. printf("%p\n", ptr);
7. }
a) 5
b) Address of 5
c) Nothing
d) Compile time error

Answer: d

66. What will be the output of the following C code?

1. #include <stdio.h>
2. void main()
3. {
4. int x = 0;
5. int *ptr = &x;
6. printf("%d\n", *ptr);
7. }
a) Address of x
b) Junk value
c) 0
d) Run time error

Answer: c
67. Which of the following can never be sent by call-by-value?
a) Variable
b) Array
c) Structures
d) Both Array and Structures

Answer: b

68. Which type of variables can have the same name in a different function?
a) Global variables
b) Static variables
c) Function arguments
d) Both static variables and Function arguments

Answer: d

69. Arguments that take input by user before running a program are called?
a) Main function arguments
b) Main arguments
c) Command-Line arguments
d) Parameterized arguments

Answer: c

70. What is the maximum number of arguments that can be passed in a single function?
a) 127
b) 253
c) 361
d) No limits in number of arguments

Answer: b

71. What will be the output of the following C code?

1. #include <stdio.h>
2. void m(int *p, int *q)
3. {
4. int temp = *p; *p = *q; *q = temp;
5. }
6. void main()
7. {
8. int a = 6, b = 5;
9. m(&a, &b);
10. printf("%d %d\n", a, b);
11. }
a) 5 6
b) 6 5
c) 5 5
d) 6 6

Answer: a

72. What will be the output of the following C code?

1. #include <stdio.h>
2. void m(int *p)
3. {
4. int i = 0;
5. for(i = 0;i < 5; i++)
6. printf("%d\t", p[i]);
7. }
8. void main()
9. {
10. int a[5] = {6, 5, 3};
11. m(&a);
12. }
a) 0 0 0 0 0
b) 6 5 3 0 0
c) Run time error
d) 6 5 3 junk junk

Answer: b

73. What will be the output of the following C code?

1. #include <stdio.h>
2. void m(int p, int q)
3. {
4. int temp = p;
5. p = q;
6. q = temp;
7. }
8. void main()
9. {
10. int a = 6, b = 5;
11. m(a, b);
12. printf("%d %d\n", a, b);
13. }
a) 5 6
b) 5 5
c) 6 5
d) 6 6

Answer: c
74. What will be the output of the following C code?

1. #include <stdio.h>
2. void m(int p, int q)
3. {
4. printf("%d %d\n", p, q);
5. }
6. void main()
7. {
8. int a = 6, b = 5;
9. m(a);
10. }
a) 6
b) 6 5
c) 6 junk value
d) Compile time error

Answer: d

75. What will be the output of the following C code?

1. #include <stdio.h>
2. void m(int p)
3. {
4. printf("%d\n", p);
5. }
6. void main()
7. {
8. int a = 6, b = 5;
9. m(a, b);
10. printf("%d %d\n", a, b);
11. }
a) 6
b) 6 5
c) 6 junk value
d) Compile time error

Answer: d

76. What will be the output of the following C code?

#include<stdio.h>
#define max 100
main()
{
#ifdef max
printf("hello");
}
a) 100
b) hello
c) “hello”
d) error

Answer: d

77. _______________ is the preprocessor directive which is used to end the scope of #ifdef.
a) #elif
b) #ifndef
c) #endif
d) #if

Answer: c

78. What will be the output of the following C code?

#include<stdio.h>
void main()
{
#ifndef max
printf("hello");
#endif
printf("hi");
}
a) hello
b) hellohi
c) error
d) hi

Answer: b

79. What will be the output of the following C code?

#include<stdio.h>
#define san 557
main()
{
#ifndef san
printf("yes");
#endif
printf("no");
}
a) error
b) yes
c) no
d) yesno

Answer: c

80. he preprocessor directive which checks whether a constant expression results in a zero or
non-zero value __________
a) #if
b) #ifdef
c) #undef
d) #ifndef

Answer:a

81. include<stdio.h>
#define max 100
void main()
{
#if(max%10)
printf("san");
#endif
printf("foundry");
}
a) error
b) san
c) foundry
d) sanfoundry

Answer: d

82. The preprocessor directive which is used to remove the definition of an identifier which
was previously defined with #define?
a) #ifdef
b) #undef
c) #ifndef
d) #def

Answer: b

83. What will be the output of the following C code?

#include<stdio.h>
#define hello 10
void main()
{
printf("%d",hello);
#undef hello
printf("%d",hello);
}
a) 10
b) hello
c) error
d) 1010

Answer: c

84. What will be the output of the following C code?

#include <stdio.h>
#define a 2
main()
{
int r;
#define a 5
r=a*2;
printf("%d",r);
}
a) 10
b) 4
c) 2
d) 5

Answer: a

85. What will be the output of the following C code if the value of ‘p’ is 10 and that of ‘q’ is
15?

#include<stdio.h>
int main()
{
int p,q;
printf("Enter two numbers\n");
scanf("%d",&p);
scanf("%d",&q);
#if(4<2)
printf("%d",p);
#elif(2>-1)
printf("%d",q);
#else
printf("bye");
#endif
}
a) 10
b) 15
c) bye
d) error

Answer: b

86. . What will be the output of the following C code?

1. #include <stdio.h>
2. int main()
3. {
4. double *ptr = (double *)100;
5. ptr = ptr + 2;
6. printf("%u", ptr);
7. }
a) 102
b) 104
c) 108
d) 116

Answer: d

87. . What will be the output of the following C code?

1. #include <stdio.h>
2. int main()
3. {
4. int *p = (int *)2;
5. int *q = (int *)3;
6. printf("%d", p + q);
7. }
a) 2
b) 3
c) 5
d) Compile time error

Answer: d

88. Which of the following arithmetic operation can be applied to pointers a and b?
(Assuming initialization as int *a = (int *)2; int *b = (int *)3;)
a) a + b
b) a – b
c) a * b
d) a / b

Answer: b
89. What is the size of *ptr in a 32-bit machine (Assuming initialization as int *ptr = 10;)?
a) 1
b) 2
c) 4
d) 8

Answer: c

90. Which of following logical operation can be applied to pointers?


(Assuming initialization int *a = 2; int *b = 3;)
a) a | b
b) a ^ b
c) a & b
d) None of the mentioned
Answer: d

91.What will be the output of the following C code?

1. #include <stdio.h>
2. void main()
3. {
4. char *s = “hello”;
5. char *p = s;
6. printf(“%c\t%c”, *(p + 1), s[1]);
7. }
a) h e
b) e l
c) h h
d) e e

92. What will be the output of the following C code?

1. #include <stdio.h>
2. void main()
3. {
4. char *s = "hello";
5. char *p = s;
6. printf("%c\t%c", *p, s[1]);
7. }
a) e h
b) Compile time error
c) h h
d) h e

Answer: d

93. What will be the output of the following C code?


1. #include <stdio.h>
2. void main()
3. {
4. char *s = "hello";
5. char *n = "cjn";
6. char *p = s + n;
7. printf("%c\t%c", *p, s[1]);
8. }
a) h e
b) Compile time error
c) c o
d) h n

Answer: b

94. What will be the output of the following C code?

1. #include <stdio.h>
2. void main()
3. {
4. int k = 5;
5. int *p = &k;
6. int **m = &p;
7. printf("%d%d%d\n", k, *p, **m);
8. }
a) 5 5 5
b) 5 5 junk value
c) 5 junk junk
d) Run time error

Answer: a

95. What will be the output of the following C code?

1. #include <stdio.h>
2. void main()
3. {
4. int k = 5;
5. int *p = &k;
6. int **m = &p;
7. printf("%d%d%d\n", k, *p, **p);
8. }
a) 5 5 5
b) 5 5 junk value
c) 5 junk junk
d) Compile time error
Answer: d

96. What will be the output of the following C code?

1. #include <stdio.h>
2. void main()
3. {
4. int k = 5;
5. int *p = &k;
6. int **m = &p;
7. **m = 6;
8. printf("%d\n", k);
9. }
a) 5
b) Compile time error
c) 6
d) Junk

Answer: c

97. What will be the output of the following C code?

1. #include <stdio.h>
2. void main()
3. {
4. int a[3] = {1, 2, 3};
5. int *p = a;
6. int *r = &p;
7. printf("%d", (**r));
8. }
a) 1
b) Compile time error
c) Address of a
d) Junk value

Answer: b

98. What will be the output of the following C code?

1. #include <stdio.h>
2. void main()
3. {
4. int a[3] = {1, 2, 3};
5. int *p = a;
6. int **r = &p;
7. printf("%p %p", *r, a);
8. }
a) Different address is printed
b) 1 2
c) Same address is printed
d) 1 1

Answer: c

99. . How many number of pointer (*) does C have against a pointer variable declaration?
a) 7
b) 127
c) 255
d) No limits

Answer: d

100. What will be the output of the following C code?

1. #include <stdio.h>
2. int main()
3. {
4. int a = 1, b = 2, c = 3;
5. int *ptr1 = &a, *ptr2 = &b, *ptr3 = &c;
6. int **sptr = &ptr1; //-Ref
7. *sptr = ptr2;
8. }
a) ptr1 points to a
b) ptr1 points to b
c) sptr points to ptr2
d) none of the mentioned

Answer: b
Unit 1 MCQ with answer (100 No’s)

1. All keywords in C are in ____________


a) LowerCase letters
b) UpperCase letters
c) CamelCase letters
d) None of the mentioned
Answer: a
2. Which of the following is not a valid variable name declaration?
a) int __a3;
b) int __3a;
c) int __A3;
d) None of the mentioned
Answer: d
3. Which of the following is not a valid variable name declaration?
a) int _a3;
b) int a_3;
c) int 3_a;
d) int _3a
Answer: c
4. Why do variable names beginning with the underscore is not encouraged?
a) It is not standardized
b) To avoid conflicts since assemblers and loaders use such names
c) To avoid conflicts since library routines use such names
d) To avoid conflicts with environment variables of an operating system
Answer: c
5. Variable name resolution (number of significant characters for the uniqueness of variable)
depends on ___________
a) Compiler and linker implementations
b) Assemblers and loaders implementations
c) C language
d) None of the mentioned
6. Which of the following is not a valid C variable name?
a) int number;
b) float rate;
c) int variable_count;
d) int $main;
Answer: d
7. Which of the following is true for variable names in C?
a) They can contain alphanumeric characters as well as special characters
b) It is not an error to declare a variable to be one of the keywords(like goto, static)
c) Variable names cannot start with a digit
d) Variable can be of any length
Answer: c
8. Which is valid C expression?
a) int my_num = 100,000;
b) int my_num = 100000;
c) int my num = 1000;
d) int $my_num = 10000;
Answer: b
9. What will be the output of the following C code?

1. #include <stdio.h>
2. int main()
3. {
4. printf("Hello World! %d \n", x);
5. return 0;
6. }
a) Hello World! x;
b) Hello World! followed by a junk value
c) Compile time error
d) Hello World!
Answer: c
10. What will be the output of the following C code?

1. #include <stdio.h>
2. int main()
3. {
4. int y = 10000;
5. int y = 34;
6. printf("Hello World! %d\n", y);
7. return 0;
8. }
a) Compile time error
b) Hello World! 34
c) Hello World! 1000
d) Hello World! followed by a junk value

Answer: a
11.Which of the following is not a valid variable name declaration?
a) float PI = 3.14;
b) double PI = 3.14;
c) int PI = 3.14;
d) #define PI 3.14

Answer: d

12. What will happen if the following C code is executed?

1. #include <stdio.h>
2. int main()
3. {
4. int main = 3;
5. printf("%d", main);
6. return 0;
7. }
a) It will cause a compile-time error
b) It will cause a run-time error
c) It will run without any error and prints 3
d) It will experience infinite looping

Answer: c

13. What is the problem in the following variable declaration?

float 3Bedroom-Hall-Kitchen?;

a) The variable name begins with an integer


b) The special character ‘-‘
c) The special character ‘?’
d) All of the mentioned

Answer: d

14. What will be the output of the following C code?

1. #include <stdio.h>
2. int main()
3. {
4. int ThisIsVariableName = 12;
5. int ThisIsVariablename = 14;
6. printf("%d", ThisIsVariablename);
7. return 0;
8. }
a) The program will print 12
b) The program will print 14
c) The program will have a runtime error
d) The program will cause a compile-time error due to redeclaration

Answer: b

15. Which of the following cannot be a variable name in C?


a) volatile
b) true
c) friend
d) export

Answer: a

16. What will be the output of the following C code?

1. #include <stdio.h>
2. int main()
3. {
4. int a[5] = {1, 2, 3, 4, 5};
5. int i;
6. for (i = 0; i < 5; i++)
7. if ((char)a[i] == '5')
8. printf("%d\n", a[i]);
9. else
10. printf("FAIL\n");
11. }
a) The compiler will flag an error
b) The program will compile and print the output 5
c) The program will compile and print the ASCII value of 5
d) The program will compile and print FAIL for 5 times

Answer: d

17.The format identifier ‘%i’ is also used for _____ data type.
a) char
b) int
c) float
d) double

Answer: b

18.Which data type is most suitable for storing a number 65000 in a 32-bit system?
a) signed short
b) unsigned short
c) long
d) int

Answer: b

19.Which of the following is a User-defined data type?


a) typedef int Boolean;
b) typedef enum {Mon, Tue, Wed, Thu, Fri} Workdays;
c) struct {char name[10], int age};
d) all of the mentioned

Answer: d

20.What is the size of an int data type?


a) 4 Bytes
b) 8 Bytes
c) Depends on the system/compiler
d) Cannot be determined

Answer: c

21.What will be the output of the following C code?

1. #include <stdio.h>
2. int main()
3. {
4. signed char chr;
5. chr = 128;
6. printf("%d\n", chr);
7. return 0;
8. }
a) 128
b) -128
c) Depends on the compiler
d) None of the mentioned

Answer: b

22.What is short int in C programming?


a) The basic data type of C
b) Qualifier
c) Short is the qualifier and int is the basic data type
d) All of the mentioned
Answer: c

23. What will be the output of the following C code?

1. #include <stdio.h>
2. int main()
3. {
4. float f1 = 0.1;
5. if (f1 == 0.1)
6. printf("equal\n");
7. else
8. printf("not equal\n");
9. }
a) equal
b) not equal
c) output depends on the compiler
d) error

Answer: b

24. What will be the output of the following C code?

1. #include <stdio.h>
2. int main()
3. {
4. float f1 = 0.1;
5. if (f1 == 0.1f)
6. printf("equal\n");
7. else
8. printf("not equal\n");
9. }
a) equal
b) not equal
c) output depends on compiler
d) error

Answer: a

25. What will be the output of the following C code on a 32-bit machine?

1. #include <stdio.h>
2. int main()
3. {
4. int x = 10000;
5. double y = 56;
6. int *p = &x;
7. double *q = &y;
8. printf("p and q are %d and %d", sizeof(p), sizeof(q));
9. return 0;
10. }
a) p and q are 4 and 4
b) p and q are 4 and 8
c) compiler error

d) p and q are 2 and 8

Answer: a

26.Which is correct with respect to the size of the data types?


a) char > int > float
b) int > char > float
c) char < int < double
d) double > char > int

Answer: c

27. What will be the output of the following C code on a 64 bit machine?

1. #include <stdio.h>
2. union Sti
3. {
4. int nu;
5. char m;
6. };
7. int main()
8. {
9. union Sti s;
10. printf("%d", sizeof(s));
11. return 0;
12. }
a) 8
b) 5
c) 9
d) 4

Answer: d

28.What will be the output of the following C code?

1. #include <stdio.h>
2. int main()
3. {
4. float x = 'a';
5. printf("%f", x);
6. return 0;
7. }
a) a
b) run time error
c) a.0000000
d) 97.000000

Answer: d

29.Which of the data types has the size that is variable?


a) int
b) struct
c) float
d) double

Answer: b

30. What will be the output of the following C code?

1. #include <stdio.h>
2. int main()
3. {
4. printf("C programming %s", "Class by\n%s Sanfoundry", "WOW");
5. }
a)

C programming Class by

WOW Sanfoundry

b) C programming Class by\n%s Sanfoundry


c)

C programming Class by

%s Sanfoundry

d) Compilation error

31. In the following code snippet, character pointer str holds a reference to the string
___________

char *str = "Sanfoundry.com\0" "training classes";


a) Sanfoundry.com
b) Sanfoundry.com\0training classes
c) Sanfoundry.comtraining classes
d) Invalid declaration

Answer: b

32. What will be the output of the following C code?

1. #include <stdio.h>
2. #define a 10
3. int main()
4. {
5. const int a = 5;
6. printf("a = %d\n", a);
7. }
a) a = 5
b) a = 10
c) Compilation error
d) Runtime error

Answer: c

33. What will be the output of the following C code?

1. #include <stdio.h>
2. int main()
3. {
4. int var = 010;
5. printf("%d", var);
6. }
a) 2
b) 8
c) 9
d) 10

Answer: b

34. What will be the output of the following C code?

1. #include <stdio.h>
2. #include <string.h>
3. int main()
4. {
5. char *str = "x";
6. char c = 'x';
7. char ary[1];
8. ary[0] = c;
9. printf("%d %d", strlen(str), strlen(ary));
10. return 0;
11. }
a) 1 1
b) 2 1
c) 2 2
d) 1 (undefined value)

Answer: d

35. What will be the output of the following C code?

1. #include <stdio.h>
2. void foo(const int *);
3. int main()
4. {
5. const int i = 10;
6. printf("%d ", i);
7. foo(&i);
8. printf("%d", i);
9.
10. }
11. void foo(const int *i)
12. {
13. *i = 20;
14. }
a) Compile time error
b) 10 20
c) Undefined value
d) 10

Answer: a

36. What will be the output of the following C code?

1. #include <stdio.h>
2. int main()
3. {
4. const int i = 10;
5. int *ptr = &i;
6. *ptr = 20;
7. printf("%d\n", i);
8. return 0;
9. }
a) Compile time error
b) Compile time warning and printf displays 20
c) Undefined behaviour
d) 10

Answer: b

37. What will be the output of the following C code?

1. #include <stdio.h>
2. int main()
3. {
4. j = 10;
5. printf("%d\n", j++);
6. return 0;
7. }
a) 10
b) 11
c) Compile time error
d) 0

Answer: c

38. Will the following C code compile without any error?

1. #include <stdio.h>
2. int main()
3. {
4. for (int k = 0; k < 10; k++);
5. return 0;
6. }
a) Yes
b) No
c) Depends on the C standard implemented by compilers
d) Error

Answer: c

39. Will the following C code compile without any error?

1. #include <stdio.h>
2. int main()
3. {
4. int k;
5. {
6. int k;
7. for (k = 0; k < 10; k++);
8. }
9. }
a) Yes
b) No
c) Depends on the compiler
d) Depends on the C standard implemented by compilers

Answer: a

40. Which of the following declaration is not supported by C?


a) String str;
b) char *str;
c) float str = 3e2;
d) Both String str; & float str = 3e2;

Answer: a

41.Which of the following format identifier can never be used for the variable var?

1. #include <stdio.h>
2. int main()
3. {
4. char *var = "Advanced Training in C by Sanfoundry.com";
5. }
a) %f
b) %d
c) %c
d) %s

Answer: a

42. Which of the following declaration is illegal?


a) char *str = “Best C programming classes by Sanfoundry”;
b) char str[] = “Best C programming classes by Sanfoundry”;
c) char str[20] = “Best C programming classes by Sanfoundry”;
d) char[] str = “Best C programming classes by Sanfoundry”;

Answer: d

43.Which keyword is used to prevent any changes in the variable within a C program?
a) immutable
b) mutable
c) const
d) volatile
Answer: c

44.Which of the following is not a pointer declaration?


a) char a[10];
b) char a[] = {‘1’, ‘2’, ‘3’, ‘4’};
c) char *str;
d) char a;

Answer: d

45.What will be the output of the following C code?

1. #include <stdio.h>
2. void main()
3. {
4. int k = 4;
5. float k = 4;
6. printf("%d", k)
7. }
a) Compile time error
b) 4
c) 4.0000000
d) 4.4

Answer: a

46. Which of the following statement is false?


a) A variable defined once can be defined again with different scope
b) A single variable cannot be defined with two different types in the same scope
c) A variable must be declared and defined at the same time
d) A variable refers to a location in memory

Answer: c

47.A variable declared in a function can be used in main().


a) True
b) False
c) True if it is declared static
d) None of the mentioned

Answer: b

48.The name of the variable used in one function cannot be used in another function.
a) True
b) False
Answer: b

49.What will be the output of the following C code?

1. #include <stdio.h>
2. int main()
3. {
4. int i = -3;
5. int k = i % 2;
6. printf("%d\n", k);
7. }
a) Compile time error
b) -1
c) 1
d) Implementation defined

Answer: b

50. What will be the output of the following C code?

1. #include <stdio.h>
2. int main()
3. {
4. int i = 3;
5. int l = i / -2;
6. int k = i % -2;
7. printf("%d %d\n", l, k);
8. return 0;
9. }
a) Compile time error
b) -1 1
c) 1 -1
d) Implementation defined

Answer: b

51.What will be the output of the following C code?

1. #include <stdio.h>
2. int main()
3. {
4. int i = 5;
5. i = i / 3;
6. printf("%d\n", i);
7. return 0;
8. }
a) Implementation defined
b) 1
c) 3
d) Compile time error

Answer: b

52. What will be the output of the following C code?

1. #include <stdio.h>
2. int main()
3. {
4. int i = -5;
5. i = i / 3;
6. printf("%d\n", i);
7. return 0;
8. }
a) Implementation defined
b) -1
c) -3
d) Compile time error

Answer: b

53. What will be the final value of x in the following C code?

1. #include <stdio.h>
2. void main()
3. {
4. int x = 5 * 9 / 3 + 9;
5. }
a) 3.75
b) Depends on compiler
c) 24
d) 3

Answer: c

54. What will be the output of the following C code?

1. #include <stdio.h>
2. void main()
3. {
4. int x = 5.3 % 2;
5. printf("Value of x is %d", x);
6. }
a) Value of x is 2.3
b) Value of x is 1
c) Value of x is 0.3
d) Compile time error

Answer: d

55. What will be the output of the following C code?

1. #include <stdio.h>
2. void main()
3. {
4. int y = 3;
5. int x = 5 % 2 * 3 / 2;
6. printf("Value of x is %d", x);
7. }
a) Value of x is 1
b) Value of x is 2
c) Value of x is 3
d) Compile time error

Answer: a

56. What will be the output of the following C code?

1. #include <stdio.h>
2. void main()
3. {
4. int a = 3;
5. int b = ++a + a++ + --a;
6. printf("Value of b is %d", b);
7. }
a) Value of x is 12
b) Value of x is 13
c) Value of x is 10
d) Undefined behaviour

Answer: d

57. What is the precedence of arithmetic operators (from highest to lowest)?


a) %, *, /, +, –
b) %, +, /, *, –
c) +, -, %, *, /
d) %, +, -, *, /

Answer: a
58. Which of the following is not an arithmetic operation?
a) a * = 10;
b) a / = 10;
c) a ! = 10;
d) a % = 10;

Answer: c

59. Which of the following data type will throw an error on modulus operation(%)?
a) char
b) short
c) int
d) float

Answer: d

60. Which among the following are the fundamental arithmetic operators, i.e, performing the
desired operation can be done using that operator only?
a) +, –
b) +, -, %
c) +, -, *, /
d) +, -, *, /, %

Answer: a

61. What will be the output of the following C code?

1. #include <stdio.h>
2. int main()
3. {
4. int a = 10;
5. double b = 5.6;
6. int c;
7. c = a + b;
8. printf("%d", c);
9. }
a) 15
b) 16
c) 15.6
d) 10

Answer: a

62.What will be the output of the following C code?

1. #include <stdio.h>
2. int main()
3. {
4. int a = 10, b = 5, c = 5;
5. int d;
6. d = a == (b + c);
7. printf("%d", d);
8. }
a) Syntax error
b) 1
c) 10
d) 5

Answer: b

63. What will be the output of the following C code?

1. #include <stdio.h>
2. void main()
3. {
4. int x = 1, y = 0, z = 5;
5. int a = x && y || z++;
6. printf("%d", z);
7. }
a) 6
b) 5
c) 0
d) Varies

Answer: a

64.What will be the output of the following C code?

1. #include <stdio.h>
2. void main()
3. {
4. int x = 1, y = 0, z = 5;
5. int a = x && y && z++;
6. printf("%d", z);
7. }
a) 6
b) 5
c) 0
d) Varies

Answer: b
65.What will be the output of the following C code?

1. #include <stdio.h>
2. int main()
3. {
4. int x = 1, y = 0, z = 3;
5. x > y ? printf("%d", z) : return z;
6. }
a) 3
b) 1
c) Compile time error
d) Run time error

Answer: c

66.What will be the output of the following C code?

1. #include <stdio.h>
2. void main()
3. {
4. int x = 1, z = 3;
5. int y = x << 3;
6. printf(" %d\n", y);
7. }
a) -2147483648
b) -1
c) Run time error
d) 8

Answer: d

.67. What will be the output of the following C code?

1. #include <stdio.h>
2. void main()
3. {
4. int x = 0, y = 2, z = 3;
5. int a = x & y | z;
6. printf("%d", a);
7. }
a) 3
b) 0
c) 2
d) Run time error

68. What will be the final value of j in the following C code?


1. #include <stdio.h>
2. int main()
3. {
4. int i = 0, j = 0;
5. if (i && (j = i + 10))
6. //do something
7. ;
8. }
a) 0
b) 10
c) Depends on the compiler
d) Depends on language standard

Answer: a

69. What will be the final value of j in the following C code?

1. #include <stdio.h>
2. int main()
3. {
4. int i = 10, j = 0;
5. if (i || (j = i + 10))
6. //do something
7. ;
8. }
a) 0
b) 20
c) Compile time error
d) Depends on language standard

Answer: a

70. What will be the output of the following C code?

1. #include <stdio.h>
2. int main()
3. {
4. int i = 1;
5. if (i++ && (i == 1))
6. printf("Yes\n");
7. else
8. printf("No\n");
9. }
a) Yes
b) No
c) Depends on the compiler
d) Depends on the standard
Answer: b

71.Are logical operator sequence points?


a) True
b) False
c) Depends on the compiler
d) Depends on the standard

Answer: a

72. Do logical operators in the C language are evaluated with the short circuit?
a) True
b) False
c) Depends on the compiler
d) Depends on the standard

Answer: a

73.What is the result of logical or relational expression in C?


a) True or False
b) 0 or 1
c) 0 if an expression is false and any positive number if an expression is true
d) None of the mentioned

Answer: b

74.What will be the final value of d in the following C code?

1. #include <stdio.h>
2. int main()
3. {
4. int a = 10, b = 5, c = 5;
5. int d;
6. d = b + c == a;
7. printf("%d", d);
8. }
a) Syntax error
b) 1
c) 5
d) 10

Answer: b

75. What will be the output of the following C code?

1. #include <stdio.h>
2. int main()
3. {
4. int a = 10, b = 5, c = 3;
5. b != !a;
6. c = !!a;
7. printf("%d\t%d", b, c);
8. }
a) 5 1
b) 0 3
c) 5 3
d) 1 1

Answer: a

76. Which among the following is NOT a logical or relational operator?


a) !=
b) ==
c) ||
d) =

Answer: d

77.What will be the output of the following C code?

1. #include <stdio.h>
2. int main()
3. {
4. int a = 10;
5. if (a == a--)
6. printf("TRUE 1\t");
7. a = 10;
8. if (a == --a)
9. printf("TRUE 2\t");
10. }

a) TRUE 1
b) TRUE 2
c) TRUE 1 TRUE 2
d) Compiler Dependent

Answer: d

78. Relational operators cannot be used on ____________


a) structure
b) long
c) strings
d) float

Answer: a

79. What is the difference between the following 2 codes?

1. #include <stdio.h> //Program 1


2. int main()
3. {
4. int d, a = 1, b = 2;
5. d = a++ + ++b;
6. printf("%d %d %d", d, a, b);
7. }
1. #include <stdio.h> //Program 2
2. int main()
3. {
4. int d, a = 1, b = 2;
5. d = a++ +++b;
6. printf("%d %d %d", d, a, b);
7. }
a) No difference as space doesn’t make any difference, values of a, b, d are same in both the
case
b) Space does make a difference, values of a, b, d are different
c) Program 1 has syntax error, program 2 is not
d) Program 2 has syntax error, program 1 is not

Answer: d

80. What will be the output of the following C code?

1. #include <stdio.h>
2. int main()
3. {
4. int a = 1, b = 1, c;
5. c = a++ + b;
6. printf("%d, %d", a, b);
7. }
a) a = 1, b = 1
b) a = 2, b = 1
c) a = 1, b = 2
d) a = 2, b = 2

Answer: b

81.What will be the output of the following C code?


1. #include <stdio.h>
2. int main()
3. {
4. int a = 1, b = 1, d = 1;
5. printf("%d, %d, %d", ++a + ++a+a++, a++ + ++b, ++d + d++ + a++);
6. }
a) 15, 4, 5
b) 9, 6, 9
c) 9, 3, 5
d) Undefined (Compiler Dependent)

Answer: d

82. For which of the following, “PI++;” code will fail?


a) #define PI 3.14
b) char *PI = “A”;
c) float PI = 3.14;
d) none of the Mentioned

Answer: a

83.What will be the output of the following C code?

1. #include <stdio.h>
2. int main()
3. {
4. int a = 10, b = 10;
5. if (a = 5)
6. b--;
7. printf("%d, %d", a, b--);
8. }
a) a = 10, b = 9
b) a = 10, b = 8
c) a = 5, b = 9
d) a = 5, b = 8

Answer: c

84. What will be the output of the following C code?

1. #include <stdio.h>
2. int main()
3. {
4. int i = 0;
5. int j = i++ + i;
6. printf("%d\n", j);
7. }
a) 0
b) 1
c) 2
d) Compile time error

Answer: b

85. What will be the output of the following C code?

1. #include <stdio.h>
2. int main()
3. {
4. int i = 2;
5. int j = ++i + i;
6. printf("%d\n", j);
7. }
a) 6
b) 5
c) 4
d) Compile time error

Answer: a

86. What will be the output of the following C code?

1. #include <stdio.h>
2. int main()
3. {
4. int i = 2;
5. int i = i++ + i;
6. printf("%d\n", i);
7. }
a) = operator is not a sequence point
b) ++ operator may return value with or without side effects
c) it can be evaluated as (i++)+i or i+(++i)
d) = operator is a sequence point

Answer: a

87. What will be the output of the following C code?

1. #include <stdio.h>
2. int main()
3. {
4. int i = 0;
5. int x = i++, y = ++i;
6. printf("%d % d\n", x, y);
7. return 0;
8. }
a) 0, 2
b) 0, 1
c) 1, 2
d) Undefined

Answer: a

88.What will be the output of the following C code?

1. #include <stdio.h>
2. int main()
3. {
4. int i = 10;
5. int *p = &i;
6. printf("%d\n", *p++);
7. }
a) 10
b) 11
c) Garbage value
d) Address of i

Answer: a

89.What will be the output of the following C code?

1. #include <stdio.h>
2. void main()
3. {
4. int x = 97;
5. int y = sizeof(x++);
6. printf("X is %d", x);
7. }
a) X is 97
b) X is 98
c) X is 99
d) Run time error

Answer: a

90.What will be the output of the following C code?

1. #include <stdio.h>
2. void main()
3. {
4. int x = 4, y, z;
5. y = --x;
6. z = x--;
7. printf("%d%d%d", x, y, z);
8. }
a) 3 2 3
b) 2 3 3
c) 3 2 2
d) 2 3 4

Answer: b

91.What will be the output of the following C code?

1. #include <stdio.h>
2. void main()
3. {
4. int x = 4;
5. int *p = &x;
6. int *k = p++;
7. int r = p - k;
8. printf("%d", r);
9. }
a) 4
b) 8
c) 1
d) Run time error

Answer: c

92.What will be the output of the following C code?

1. #include <stdio.h>
2. void main()
3. {
4. int a = 5, b = -7, c = 0, d;
5. d = ++a && ++b || ++c;
6. printf("\n%d%d%d%d", a, b, c, d);
7. }
a) 6 -6 0 0
b) 6 -5 0 1
c) -6 -6 0 1
d) 6 -6 0 1
Answer: d

93.What will be the output of the following C code?

1. #include <stdio.h>
2. void main()
3. {
4. int a = -5;
5. int k = (a++, ++a);
6. printf("%d\n", k);
7. }
a) -4
b) -5
c) 4
d) -3

Answer: d

94.What will be the output of the following C code?

1. #include <stdio.h>
2. int main()
3. {
4. int c = 2 ^ 3;
5. printf("%d\n", c);
6. }
a) 1
b) 8
c) 9
d) 0

Answer: a

95.What will be the output of the following C code?

1. #include <stdio.h>
2. int main()
3. {
4. unsigned int a = 10;
5. a = ~a;
6. printf("%d\n", a);
7. }
a) -9
b) -10
c) -11
d) 10
Answer: c

96. What will be the output of the following C code?

1. #include <stdio.h>
2. int main()
3. {
4. if (7 & 8)
5. printf("Honesty");
6. if ((~7 & 0x000f) == 8)
7. printf("is the best policy\n");
8. }
a) Honesty is the best policy
b) Honesty
c) is the best policy
d) No output

Answer: c

97. What will be the output of the following C code?

1. #include <stdio.h>
2. int main()
3. {
4. int a = 2;
5. if (a >> 1)
6. printf("%d\n", a);
7. }
a) 0
b) 1
c) 2
d) No Output

Answer: c

98.Comment on the output of the following C code.

1. #include <stdio.h>
2. int main()
3. {
4. int i, n, a = 4;
5. scanf("%d", &n);
6. for (i = 0; i < n; i++)
7. a = a * 2;
8. }
a) Logical Shift left
b) No output
c) Arithmetic Shift right
d) Bitwise exclusive OR

99. What will be the output of the following C code?

1. #include <stdio.h>
2. void main()
3. {
4. int x = 97;
5. int y = sizeof(x++);
6. printf("x is %d", x);
7. }
a) x is 97
b) x is 98
c) x is 99
d) Run time error

Answer: a

100. What will be the output of the following C code?

1. #include <stdio.h>
2. void main()
3. {
4. int x = 4, y, z;
5. y = --x;
6. z = x--;
7. printf("%d%d%d", x, y, z);
8. }
a) 3 2 3
b) 2 2 3
c) 3 2 2
d) 2 3 3

Answer: d

You might also like