0% found this document useful (0 votes)
8 views12 pages

Cs8451 Daa Unit 2

Uploaded by

yiriti4393
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)
8 views12 pages

Cs8451 Daa Unit 2

Uploaded by

yiriti4393
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/ 12

ChettinadTech Dept of CSE

Department of Computer Science and Engineering


CS8451 Design and Analysis of Algorithms – (6 semester, 2017 Regulation)
th

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

CS8451 Design and Analysis of Algorithms Page 1


ChettinadTech Dept of CSE

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.

5. Which of the following is similar to Euclidean distance?


a) Manhattan distance
b) Pythagoras metric
c) Chebyshev distance
d) Heuristic distance
Answer: b
Explanation: In older times, Euclidean distance metric is also called a Pythagoras metric which is the length of
the line segment connecting two points.

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

7. Which of the following strategies does the following diagram depict?

CS8451 Design and Analysis of Algorithms Page 2


ChettinadTech Dept of CSE

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.

8. Which of the points are closer to each other?

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.

9. ___________ is a method of constructing a smallest polygon out of n given points.


a) Closest pair problem
b) Quick hull problem
c) Path compression
d) Union-by-rank
Answer: b
Explanation: Quick hull is a method of constructing a smallest convex polygon out of n given points in a plane.

10. What is the other name for quick hull problem?


a) Convex hull

CS8451 Design and Analysis of Algorithms Page 3


ChettinadTech Dept of CSE

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.

12. What is the average case complexity of a quick hull algorithm?


a) O(N)
b) O(N log N)
c) O(N2)
d) O(log N)
Answer: b
Explanation: The average case complexity of quickhull algorithm using divide and conquer approach is
mathematically found to be O(N log N).

13. What is the worst case complexity of quick hull?


a) O(N)
b) O(N log N)
c) O(N2)
d) O(log N)
Answer: c
Explanation: The worst case complexity of quickhull algorithm using divide and conquer approach is
mathematically found to be O(N2).

CS8451 Design and Analysis of Algorithms Page 4


ChettinadTech Dept of CSE

14. What does the following diagram depict?

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.

15. Which of the following statement is not related to quickhull algorithm?


a) Finding points with minimum and maximum coordinates
b) Dividing the subset of points by a line
c) Eliminating points within a formed triangle
d) Finding the shortest distance between two points
Answer: d
Explanation: Finding the shortest distance between two points belongs to closest pair algorithm while the rest is
quickhull.

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.

17. To which type of problems does quick hull belong to?


a) Numerical problems
b) Computational geometry
c) Graph problems

CS8451 Design and Analysis of Algorithms Page 5


ChettinadTech Dept of CSE

d) String problems
Answer: b
Explanation: Quick hull problem and closest pair algorithms are some of the examples of computational
problems.

18. Which of the following algorithms is similar to a quickhull algorithm?


a) Merge sort
b) Shell sort
c) Selection sort
d) Quick sort
Answer: d
Explanation: Quickhull algorithm is similar to a quick sort algorithm with respect to the run time average case
and worst case efficiencies.

19. Who formulated quick hull algorithm?


a) Eddy
b) Andrew
c) Chan
d) Graham
Answer: a
Explanation: Eddy formulated quick hull algorithm. Graham invented graham scan. Andrew formulated
Andrew’s algorithm and Chan invented Chan’s algorithm.

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

CS8451 Design and Analysis of Algorithms Page 6


ChettinadTech Dept of CSE

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.

22. What is the average case time complexity of merge sort?


a) O(n log n)
b) O(n2)
c) O(n2 log n)
d) O(n log n2)
Answer: a
Explanation: The recurrence relation for merge sort is given by T(n) = 2T(n/2) + n. It is found to be equal to O(n
log n) using the master theorem.

23. What is the auxiliary space complexity of merge sort?


a) O(1)
b) O(log n)
c) O(n)
d) O(n log n)
Answer: c
Explanation: An additional space of O(n) is required in order to merge two sorted arrays. Thus merge sort is not
an in place sorting algorithm.

24. Which of the following method is used for sorting in merge sort?
a) Merging
b) Partitioning
c) Selection
d) Exchanging
Answer: a

CS8451 Design and Analysis of Algorithms Page 7


ChettinadTech Dept of CSE

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.

26. Which of the following sorting algorithms is the fastest?


a) Merge sort
b) Quick sort
c) Insertion sort
d) Shell sort
Answer: b
Explanation: Quick sort is the fastest known sorting algorithm because of its highly optimized inner loop.

27. Quick sort follows Divide-and-Conquer strategy.


a) True
b) False
Answer: a
Explanation: In quick sort, the array is divided into sub-arrays and then it is sorted (divide-and-conquer strategy).

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

CS8451 Design and Analysis of Algorithms Page 8


ChettinadTech Dept of CSE

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.

31. 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
Explanation: This is the safest method to choose the pivot element since it is very unlikely that a random pivot
would consistently provide a poor partition.

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

CS8451 Design and Analysis of Algorithms Page 9


ChettinadTech Dept of CSE

Explanation: The best case and average case analysis of a quick sort algorithm are mathematically found to be
O(N log N).

33. 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
Explanation: Choosing the first element as pivot is the worst method because if the input is pre-sorted or in
reverse order, then the pivot provides a poor partition.

34. On which algorithm is heap sort based on?


a) Fibonacci heap
b) Binary tree
c) Priority queue
d) FIFO
Answer: c
Explanation: Heap sort is based on the algorithm of priority queue and it gives the best sorting time.

35. In what time can a binary heap be built?


a) O(N)
b) O(N log N)
c) O(log N)
d) O(N2)
Answer: a
Explanation: The basic strategy is to build a binary heap of N elements which takes O(N) time.

36. What is the objective of the knapsack problem?


a) To get maximum total value in the knapsack
b) To get minimum total value in the knapsack
c) To get maximum weight in the knapsack
d) To get minimum weight in the knapsack
Answer: a

CS8451 Design and Analysis of Algorithms Page 10


ChettinadTech Dept of CSE

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.

39. Heap sort is an implementation of ____________ using a descending priority queue.


a) Insertion sort
b) Selection sort
c) Bubble sort
d) Merge sort
Answer: b

CS8451 Design and Analysis of Algorithms Page 11


ChettinadTech Dept of CSE

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.

CS8451 Design and Analysis of Algorithms Page 12

You might also like