Dsa Quiz 3

You might also like

Download as pdf
Download as pdf
You are on page 1of 10
Sorting_Searching Quiz(MCA-III) Sorting_Searching Quiz * Required 1, Email * 2. Name* 3. Section * Mark only one oval. COa COs 4. University Roll Number * ‘Suppose we have a O(n) time algorithm that finds median of an unsorted * 1 point array.Now consider a QuickSort implementation where we first find median using the above algorithm, then use median as pivot. What will be the worst case time complexity of this modified QuickSort. Mark only one oval. ©) 0(n2 Logn) © oma) What is recurrence for worst case of QuickSort and what is the time * 1 point complexity in Worst case? Mark only one oval. —_) Recurrence is T(n) = T(n-2) + O(n) and time complexity is O(n*2) ) Recurrence is T(n) = T(n-1) + O(n) and time complexity is O(n*2) aA ») Recurrence is T(n) = 2T(n/2) + O(n) and time complexity is O(nLogn) (—) Recurrence is T(n) = T(n/10) + T(9n/10) + O(n) and time complexity is O(nLogn) Which of the following is not a stable sorting algorithm in its typical * 1 point implementation. Mark only one oval. ) auick sort ) Bubble Sort 8. Suppose we are sorting an array of eight integers using quicksort, and we * 1 point have just finished the first partitioning with the array looking like this:2 5 17 9 12 11 10 Which statement is correct? Mark only one oval. (_) The pivot could be either the 7 or the 9. (_) The pivot could be the 7, but it is not the 9 (—) The pivot is not the 7, but it could be the 9 -) Neither the 7 nor the 9 is the pivot. 9, What is the worst case complexity of selection sort? * 1 point Mark only one oval. ©) o(nlogn) €) oftogn) Oo) ») 0(n'2) 10. Where is linear searching used? * 1 point Mark only one oval. (—) When the list has only a few elements When performing a single search in an unordered list, (_D Used all the time (—) When the list has only a few elements and When performing a single search in an unordered list 11. 12. 13. What is the best case for linear search? * Mark only one oval. What is the worst case for linear search? * Mark only one oval. Binary Search can be categorized into which of the following? * Mark only one oval. Brute Force technique () Divide and conquer ) Greedy algorithm (_) Dynamic programming 1 point 1 point 1 point 14. 15. How many passes does an insertion sort algorithm consist of? * 1 point Mark only one oval. Which one of the following is the recurrence equation for the worst case * ‘point time complexity of the Quicksort algorithm for sorting n(2 2) numbers? In the recurrence equations given in the options below, c is a constant. Mark only one oval. C) Tn) = 27 (0/2) + en ©) 1m) = 27 (n= 2) +n () T(n) = T(n/2) + en Assume that the algorithms considered here sort the input sequences in ascending order. If the input is already in ascending order, which of the following are TRUE ? Quicksort runs in @(n*2) time Bubblesort runs in @(n*2) time Merge sort runs in @(n) time IV. Insertion sort runs in @(n) time 16. * 1 point Mark only one oval. ©) Nand Il only ©) land ill only (9 tand IV only CO land Iv only 17. Consider the array Al]= {6,4,8,1,3) apply the insertion sort to sort the array Consider the cost associated with each sort is 25 rupees , what is the total cost of the insertion sort when element 1 reaches the first position of the array ? Mark only one oval. 18. Which of the following algorithm design technique is used in merge sort? * Mark only one oval. ( Greedy method ») Backtracking >) Dynamic programming Divide and Conquer state true or false ‘A. Binary Search is used to search ina sorted array B. Time complexity of binary search is O(log n) 19. Mark only one oval. © True,True True, False ) False, True ) False, False * 1 point 1 point 1 point 20. Which is not internal sorting * 1 point Mark only one oval. Insertion Sort () Bubble Sort () Merge Sort » Heap Sort 21. Which of the following sorting algorithms is/are stable * 1 point Mark only one oval. ©) Counting sort () Bucket sort (Radix sort ( Allof the above 22. Counting sort performs Numbers of comparisons between input * 1 point elements. Mark only one oval. Coo On ©) nlogn 23. Asorting technique is called stable if it * 1 point Mark only one oval. Takes O(nlogn) times (—) Maintains the relative order of occurrence of non-distinct elements () Uses divide-and-conquer paradigm (_) Takes O(n) space 24. Inabinary max heap containing n numbers, the smallest element canbe * i point found in time Mark only one oval. 2 8(n) © (logn) (©) @ (loglogn) Ce) 25. Which one of the following sorting algorithm is best suited to sort an array * 1 point of 1 million elements? Mark only one oval. (> Bubble sort (—) Insertion sort () Merge sort ) Quick sort 26. Amachine needs a minimum of 200 sec to sort 1000 elements by Quick —* 1 point sort, The minimum time needed to sort 200 elements will be approximately Mark only one oval. ©) 60.2 sec (45.54 sec 31.11 sec ) 20sec The essential part of Heap sort is construction of max-heap. 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? 27, * 1 point Mark only one oval. Oo4 Os oe Os 28. How many comparisons will be made to sort the array arr=(1, 5, 3,8, 2) * Ipoint using bucket sort? Mark only one oval. Cc 5 7 9 Oo 29. Given an array arr = {5,6,77,88,99} and key = 88; How many iterations are * {point done until the element is found? Mark only one oval. 1 COs Co4 Oz This content is neither created nor endorsed by Google Google Forms

You might also like