0% found this document useful (0 votes)
6 views4 pages

Tab DAA - S1 - 1446 With Key - MIDTERM SOlution

Gg
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)
6 views4 pages

Tab DAA - S1 - 1446 With Key - MIDTERM SOlution

Gg
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/ 4

Question 1: Multiple Choice Questions 1 X10= 10

1. What is the average time complexity of quick sort?

a. O(logn) b. O(n) c. O(n2) d.O(nlogn)

2. Search always implemented on sorted array

a. Binary Search b. Linear Search c. Both a and B d. None

3. Divide and conquer algorithm :

a. Merge Sort b. Bubble sort c. Insertion sort d. N one

4. What does the term 'heuristic' mean?

a. Encouraging self-discovery and problem-solving through experimentation

b. Learning through repetition

c. Following fixed instructions to solve problems

d. None

5. What will be the recurrence relation for the following method:

public int g(int n) {

if (n==1)

return 2;

else

return 3 *g(n/2)+ g(n/2) +5 : }

a. T(1) =c

T(n) = b+ 2T(n/2)

b. T(0) =c

T(n) = b+ 2T(n/2)

c. T(1) =c

T(n) = b+ T(n/2)

d. None

6. Probabilistic algorithm
Page 1 of 4
a. Randomize Quick Sort b. Insertion Sort c. Merge Sort d. None

7. Algorithms should end in a finite number of steps is referred to:

a. Definiteness b. Finiteness c. complexity d. Effectiveness

8. When the array is sorted or almost sorted is better to use ……. Sort to achieve the best
performance.

a. Bubble sort b. Insertion sort c. Merge sort d. Quick sort

9. Which of the following is not an in-place algorithm?

a. Bubble sort b. Insertion sort c. Merge sort d. Heap sort

10. Recurrence relation of merge sort is:

a. T(n) = T(n/2) +O(n) b. T(n) = 2T(n/2) +O( n)

c. T(n) = 2T(2/n) + O(n) d. T(n) = 2T(n/2) + O(n)2

Question 2: True/False 1 X7 = 7

11. The average running time of merge sort algorithm is O(nlogn)

a.True b. False

12. Running time of Quicksort when levels alternate between good and bad splits is O(n)

a.True b. False

13. Linear Search: A search traverses the collection until the desired element is found:

a.True b. False

14. Binary search reduces the work by half at each comparison

a.True b. False

15. Approximate Algorithm: An answer is obtained that is as precise as required

a.True b. False

16. A recurrence relation, T(n), is a recursive function of an integer variable n

a.True b. False

Page 2 of 4
17. Combine: The subproblem solution to get the solution to the original problem

a.True b. False

Question 3: Short answer questions 1.5 X2= 3

18. Form and solve the recurrence relation for the running time of factorial method and
hence determine its big-O complexity:

long factorial (int n) {

if (n == 0)

return 1;

else

return n * factorial (n – 1);

Answer

Page 3 of 4
19. Given a sorted array, how many comparisons are required to find the element 42 using
Binary Search? Write all the steps

7 12 42 59 71 86 104 212

42 found – in 3 comparisons

Page 4 of 4

You might also like