Cs8451 Daa Unit 2
Cs8451 Daa Unit 2
MCQ Bank
Unit II – Brute Force and Divide and Conquer
1. Which of the following areas do closest pair problem arise?
a) Computational geometry
b) Graph Coloring problems
c) Numerical problems
d) String matching
Answer: a
Explanation: Closest pair problem arises in two most important areas- computational geometry and operational
research.
2. Which approach is based on computing the distance between each pair of distinct points and finding a pair with
the smallest distance?
a) Brute force
b) Exhaustive search
c) Divide and conquer
d) Branch and bound
Answer: a
Explanation: Brute force is a straight forward approach that solves closest pair problem using that algorithm.
3. What is the runtime efficiency of using brute force technique for the closest pair problem?
a) O(N)
b) O(N log N)
c) O(N2)
d) O(N3 log N)
Answer: c
Explanation: The efficiency of closest pair algorithm by brute force technique is mathematically found to be
O(N2).
4. What is the basic operation of closest pair algorithm using brute force technique?
a) Euclidean distance
b) Radius
c) Area
d) Manhattan distance
Answer: a
Explanation: The basic operation of closest pair algorithm is Euclidean distance and its formula is given by
d=√(xi-xj)2+(yi-yj)2.
6. What is the optimal time required for solving the closest pair problem using divide and conquer approach?
a) O(N)
b) O(log N)
c) O(N log N)
d) O(N2)
Answer: c
Explanation: The optimal time for solving using a divide and conquer approach is mathematically found to be
O(N log N).
a) Brute force
b) Divide and conquer
c) Exhaustive search
d) Branch and bound
Answer: b
Explanation: The above diagram depicts the implementation of divide and conquer. The problem is divided into
sub problems and are separated by a line.
a) p1 and p11
b) p3 and p8
c) p2 and p3
d) p9 and p10
Answer: c
Explanation: From symmetry, we determine that the closest pair is p2 and p3. But the exact calculations have to
be done using Euclid’s algorithm.
b) Concave hull
c) Closest pair
d) Path compression
Answer: a
Explanation: The other name for quick hull problem is convex hull problem whereas the closest pair problem is
the problem of finding the closest distance between two points.
11. How many approaches can be applied to solve quick hull problem?
a) 1
b) 2
c) 3
d) 4
Answer: b
Explanation: Most commonly, two approaches are adopted to solve quick hull problem- brute force approach and
divide and conquer approach.
a) Closest pair
b) Convex hull
c) Concave hull
d) Path compression
Answer: b
Explanation: The above diagram is a depiction of convex hull, also known as quick hull, since it encloses n
points into a convex polygon.
16. The quick hull algorithm runs faster if the input uses non- extreme points.
a) True
b) False
Answer: a
Explanation: It is proved that the quick hull algorithm runs faster if the input uses non-extreme points and also, if
it uses less memory.
d) String problems
Answer: b
Explanation: Quick hull problem and closest pair algorithms are some of the examples of computational
problems.
20. The time is taken to find the ‘n’ points that lie in a convex quadrilateral is?
a) O(N)
b) O(N log N)
c) O(N2)
d) O(log N)
Answer: a
Explanation: The time taken to find the ‘n’ points that lie in a convex quadrilateral is mathematically found to be
O(N).
21. Merge sort uses which of the following technique to implement sorting?
a) backtracking
b) greedy algorithm
c) divide and conquer
d) dynamic programming
Answer: c
Explanation: Merge sort uses divide and conquer in order to sort a given array. This is because it divides the
array into two halves and applies merge sort algorithm to each half individually after which the two sorted halves
are merged together.
24. Which of the following method is used for sorting in merge sort?
a) Merging
b) Partitioning
c) Selection
d) Exchanging
Answer: a
Explanation: Merge sort algorithm divides the array into two halves and applies merge sort algorithm to each
half individually after which the two sorted halves are merged together. Thus its method of sorting is called
merging.
25. 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
Explanation: Insertion sort takes linear time to sort a partially sorted array. Though merge and quick sort takes
O(n*logn) complexity to sort, merge sort is stable. Hence, Merge sort takes less time to sort partially sorted array.
28. 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
Explanation: The worst case performance of a quick sort algorithm is mathematically found to be O(N2).
29. 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
Explanation: Median-of-three partitioning is the best method for choosing an appropriate pivot element. Picking
a first, last or random element as a pivot is not much effective.
30. 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
Explanation: Left element=8, right element=0,
Centre=[position(left+right)/2]=6.
Explanation: The best case and average case analysis of a quick sort algorithm are mathematically found to be
O(N log N).
Explanation: The objective is to fill the knapsack of some given volume with different materials such that the
value of selected items is maximized.
37. Consider the following heap after buildheap phase. What will be its corresponding array?
a) 26,53,41,97,58,59,31
b) 26,31,41,53,58,59,97
c) 26,41,53,97,31,58,59
d) 97,53,59,26,41,58,31
Answer: d
Explanation: Constructing a max heap using the elements 97,53,59,26,41,58,31 will cause the heap to look like
that.
38. In heap sort, after deleting the last minimum element, the array will contain elements in?
a) Increasing sorting order
b) Decreasing sorting order
c) Tree inorder
d) Tree preorder
Answer: b
Explanation: By logic, after deleting minimum element, the heap will contain elements in decreasing sorting
order. We can change this by altering the ordering property.
Explanation: Heap sort is an implementation of selection sort using the input array as a heap representing a
descending priority queue. Heap sort algorithm is divided into two phase. In first phase the max-heap is created
and the second phase (selection phase) deletes the elements from the priority queue using sift down operation.
The essential part of Heap sort is construction of max-heap.
40. Consider the tree shown below; the node 24 violates the max-heap property. Once heapify procedure is
applied to it, which position will it be in?
a) 4
b) 5
c) 8
d) 9
Answer: d
Explanation: In max-heap element at each node is smaller than or equal to the element at its parent node. On
applying the heapify procedure on item at position 2, it will be in position 9 as shown below.