Computer Science Engineering (CSE) Exam  >  Computer Science Engineering (CSE) Tests  >  Question Bank for GATE Computer Science Engineering  >  Test: Asymptotic Analysis of Algorithms- 2 - Computer Science Engineering (CSE) MCQ

Test: Asymptotic Analysis of Algorithms- 2 - Computer Science Engineering (CSE) MCQ


Test Description

20 Questions MCQ Test Question Bank for GATE Computer Science Engineering - Test: Asymptotic Analysis of Algorithms- 2

Test: Asymptotic Analysis of Algorithms- 2 for Computer Science Engineering (CSE) 2024 is part of Question Bank for GATE Computer Science Engineering preparation. The Test: Asymptotic Analysis of Algorithms- 2 questions and answers have been prepared according to the Computer Science Engineering (CSE) exam syllabus.The Test: Asymptotic Analysis of Algorithms- 2 MCQs are made for Computer Science Engineering (CSE) 2024 Exam. Find important definitions, questions, notes, meanings, examples, exercises, MCQs and online tests for Test: Asymptotic Analysis of Algorithms- 2 below.
Solutions of Test: Asymptotic Analysis of Algorithms- 2 questions in English are available as part of our Question Bank for GATE Computer Science Engineering for Computer Science Engineering (CSE) & Test: Asymptotic Analysis of Algorithms- 2 solutions in Hindi for Question Bank for GATE Computer Science Engineering course. Download more important topics, notes, lectures and mock test series for Computer Science Engineering (CSE) Exam by signing up for free. Attempt Test: Asymptotic Analysis of Algorithms- 2 | 20 questions in 55 minutes | Mock test for Computer Science Engineering (CSE) preparation | Free important questions MCQ to study Question Bank for GATE Computer Science Engineering for Computer Science Engineering (CSE) Exam | Download free PDF with solutions
Test: Asymptotic Analysis of Algorithms- 2 - Question 1

Randomized quicksort is an extension of quicksort where the pivot is chosen randomly. What is the worst case complexity of sorting n numbers using randomized quicksort?

Detailed Solution for Test: Asymptotic Analysis of Algorithms- 2 - Question 1

Randomized quicksort has expected time complexity as O(nLogn), but worst case time complexity remains same. In worst case the randomized function can pick the index of corner element every time.

Test: Asymptotic Analysis of Algorithms- 2 - Question 2

Which one of the following is the recurrence equation for the worst case time complexity of the Quicksort algorithm for sorting n(≥ 2) numbers? In the recurrence equations given in the options below, c is a constant.

Detailed Solution for Test: Asymptotic Analysis of Algorithms- 2 - Question 2

In worst case, the chosen pivot is always placed at a corner position and recursive call is made for following. a) for subarray on left of pivot which is of size n-1 in worst case. b) for subarray on right of pivot which is of size 0 in worst case.

1 Crore+ students have signed up on EduRev. Have you? Download the App
Test: Asymptotic Analysis of Algorithms- 2 - Question 3

An unordered list contains n distinct elements. The number of comparisons to find an element in this list that is neither maximum nor minimum is

Detailed Solution for Test: Asymptotic Analysis of Algorithms- 2 - Question 3

We only need to consider any 3 elements and compare them. So the number of comparisons is constants, that makes time complexity as Θ(1) The catch here is, we need to return any element that is neither maximum not minimum. Let us take an array {10, 20, 15, 7, 90}. Output can be 10 or 15 or 20 Pick any three elements from given liar. Let the three elements be 10, 20 and 7. Using 3 comparisons, we can find that the middle element is 10.

Test: Asymptotic Analysis of Algorithms- 2 - Question 4

A problem in NP is NP-complete if 

Detailed Solution for Test: Asymptotic Analysis of Algorithms- 2 - Question 4

A problem in NP becomes NPC if all NP problems can be reduced to it in polynomial time. This is same as reducing any of the NPC problem to it. 3-SAT being an NPC problem, reducing it to a NP problem would mean that NP problem is NPC.

Test: Asymptotic Analysis of Algorithms- 2 - Question 5

What is the size of the smallest MIS(Maximal Independent Set) of a chain of nine nodes?

Detailed Solution for Test: Asymptotic Analysis of Algorithms- 2 - Question 5

A set of vertices is called independent set such that no two vertices in the set are adjacent. A maximal independent set (MIS) is an independent set which is not subset of any other independent set. The question is about smallest MIS. We can see in below diagram, the three highlighted vertices (2nd, 5th and 8th) form a maximal independent set (not subset of any other MIS) and smallest MIS.
0----0----0----0----0----0----0----0----0

Test: Asymptotic Analysis of Algorithms- 2 - Question 6

If we use Radix Sort to sort n integers in the range (nk/2,nk], for some k>0 which is independent of n, the time taken would be?

Detailed Solution for Test: Asymptotic Analysis of Algorithms- 2 - Question 6

Radix sort time complexity = O(wn)
for n keys of word size= w
⇒w = log(nk)
O(wn)=O(klogn.n)
⇒ kO(nlogn)

Test: Asymptotic Analysis of Algorithms- 2 - Question 7

The auxiliary space of insertion sort is O(1), what does O(1) mean ?

Detailed Solution for Test: Asymptotic Analysis of Algorithms- 2 - Question 7

The term O(1) states that the space required by the insertion sort is constant i.e., space required doesn't depend on input.

Test: Asymptotic Analysis of Algorithms- 2 - Question 8

Suppose we want to arrange the ii numbers stored in an array such that all negative values occur before all positive ones. Minimum number of exchanges required in the worst case is:

Detailed Solution for Test: Asymptotic Analysis of Algorithms- 2 - Question 8

When we have 'i' numbers stored in an array, we have to swap all positive numbers with negative and in worst case positive numbers will be i/2.

Test: Asymptotic Analysis of Algorithms- 2 - Question 9

The minimum number of record movements required to merge five files A (with 10 records), B (with 20 records), C (with 15 records), D (with 5 records) and E (with 25 records) is:

Detailed Solution for Test: Asymptotic Analysis of Algorithms- 2 - Question 9

Using optimal merge pattern algorithm arrange files in increasing order of records:
D  A   C     B   E

5  10  15   20  25 

Now, minimum number of record movements required = sum of internal node's value = 15 + 30 + 45 + 75 = 165 So, option (A) is correct.

Test: Asymptotic Analysis of Algorithms- 2 - Question 10

If one uses straight two-way merge sort algorithm to sort the following elements in ascending order 20, 47, 15, 8, 9, 4, 40, 30, 12, 17 then the order of these elements after the second pass of the algorithm is:

Detailed Solution for Test: Asymptotic Analysis of Algorithms- 2 - Question 10

In first pass the elements are sorted in n/4 (first 2 elements in each group) sub arrays but in second pass the elements are sorted in n/2 (first 4 elements in each group) sub arrays.

Test: Asymptotic Analysis of Algorithms- 2 - Question 11

Consider the following C function definition.
int Trial (int a, int b, int c)
{
    if ((a >= b) && (c < b) return b;
    else if (a>=b) return Trial(a, c, b);
    else return Trial(b, a, c);
}
The function Trial:

Detailed Solution for Test: Asymptotic Analysis of Algorithms- 2 - Question 11

Trial (a,b,c) return the median element of the a, b and c,but not middle element of a , b and c. But if a = b = c, then infinite loop. So, Option (D) is correct.

Test: Asymptotic Analysis of Algorithms- 2 - Question 12

Consider the following program that attempts to locate an element x in a sorted array a[ ] using binary search. Assume N>1. The program is erroneous. Under what conditions does the program fail?

var i,j,k: integer;  x: integer;
    a: array; [1....N] of integer;
begin    i:= 1; j:= N;
repeat    
    k:(i+j) div 2;
    if a[k] < x then i:= k 
    else j:= k 
until (a[k] = x) or (i >= j);
    
if (a[k] = x) then
    writeln ('x is in the array')
else
    writeln ('x is not in the array')
end;

Detailed Solution for Test: Asymptotic Analysis of Algorithms- 2 - Question 12

The above program doesn’t work for the cases where element to be searched is the last element of a[] or greater than the last element (or maximum element) in a[]. For such cases, program goes in an infinite loop because i is assigned value as k in all iterations, and i never becomes equal to or greater than j. So while condition never becomes false.

Test: Asymptotic Analysis of Algorithms- 2 - Question 13

Match the following:

Capture33

Which of the following option is correct?

Detailed Solution for Test: Asymptotic Analysis of Algorithms- 2 - Question 13

Correct matching is A – 3, B – 2, C – 4, D – 1. Option (A) is correct.

Test: Asymptotic Analysis of Algorithms- 2 - Question 14

Consider the program
void function(int n) {
int i, j, count=0;
for (i=n/2; i <= n; i++)
for (j = 1; j <= n; j = j*2)
count++;}
The complexity of the program is

Detailed Solution for Test: Asymptotic Analysis of Algorithms- 2 - Question 14

The outer loop runs n/2 times The inner loop runs logn times Therefore the total time complexity of the program is O(nlogn) which is option (D)

Test: Asymptotic Analysis of Algorithms- 2 - Question 15

If b is the branching factor and m is the maximum depth of the search tree, what is the space complexity of greedy search?

Detailed Solution for Test: Asymptotic Analysis of Algorithms- 2 - Question 15

In binary tree branching factor is 2 and space complexity for height n is O(2n).
In ternary tree branching factor is 3 and space complexity for height n is O(3n).
Similarly
If branching factor is b and height is m for search tree then space complexity of greedy search is O(bm).
So, option (C) is correct.

Test: Asymptotic Analysis of Algorithms- 2 - Question 16

The time complexity of computing the transitive closure of a binary relation on a set of n elements is known to be

Detailed Solution for Test: Asymptotic Analysis of Algorithms- 2 - Question 16

Transitive closure generally uses Floyd-Warshall Algorithm which gives a time complexity of O(n3)

Test: Asymptotic Analysis of Algorithms- 2 - Question 17

A recursive function h, is defined as follows :
h(m) = k, if m = 0
= 1, if m = 1
= 2 h(m – 1) + 4h(m – 2), if m ≥ 2
If the value of h(4) is 88 then the value of k is :

Detailed Solution for Test: Asymptotic Analysis of Algorithms- 2 - Question 17

According to given question:
h(4) = 88
88 = 2 h(3) + 4 h(2)
= 2 [2 h(2) + 4 h(1)] + 4 h(2)
= 8 h(2) + 8 h(1)
= 8 (2 + 4 k) + 8
= 24 + 32 k
 i.e.   k = 2
So, option (C) is corrct.

Test: Asymptotic Analysis of Algorithms- 2 - Question 18

Match the following with respect to algorithm paradigms :

36

Detailed Solution for Test: Asymptotic Analysis of Algorithms- 2 - Question 18
  1. Merge sort is a Divide and conquer algorithm
  2. Huffman coding is a Greedy approach
  3. Optimal polygon triangulation is Dynamic programming algorithm
  4. Subset sum problem is a Back tracking algorithm

So, option (D) is correct.

Test: Asymptotic Analysis of Algorithms- 2 - Question 19

Match the following:

36

Detailed Solution for Test: Asymptotic Analysis of Algorithms- 2 - Question 19
  1. Prim’s algorithm takes O(E lgV) time.
  2. Bellman-Ford algorithm takes O(V2E) time.
  3. Floyd-Warshall algorithm takes O(V3) time.
  4. Johnson’s algorithm takes O(VE lgV) time.

So, option (C) is correct.

Test: Asymptotic Analysis of Algorithms- 2 - Question 20

Match the following: 

35

Detailed Solution for Test: Asymptotic Analysis of Algorithms- 2 - Question 20
  • Huffman codes takes O(nlgn) time.
  • Optimal polygon triangulation takes θ(n3) time
  • Activity selection problem takes θ(n) time
  • Quicksort takes O(n2) time

So, option (C) is correct.

63 videos|7 docs|165 tests
Information about Test: Asymptotic Analysis of Algorithms- 2 Page
In this test you can find the Exam questions for Test: Asymptotic Analysis of Algorithms- 2 solved & explained in the simplest way possible. Besides giving Questions and answers for Test: Asymptotic Analysis of Algorithms- 2, EduRev gives you an ample number of Online tests for practice

Top Courses for Computer Science Engineering (CSE)

Download as PDF

Top Courses for Computer Science Engineering (CSE)