github

Made bySaurav Hathi

CSE - Mock Test - 03

Q1:

What is time complexity of fun()?

int fun(int n)

{

int count = 0;

for (int i = n; i > 0; i /= 2)

for (int j = 0; j < i; j++)

count += 1;

return count;

}

Tags:
Section:
Algorithm
Options:
Q2:

What is recurrence for worst case of Quick Sort and what is the time complexity in Worst case?

Tags:
Section:
Algorithm
Options:
Q3:

The worst case occur in quick sort when

Tags:
Section:
Algorithm
Options:
Q4:

Suppose we are sorting an array of eight integers using quicksort, and we have just finished the first partitioning with the array looking like this:

2 5 1 7 9 12 11 10

Which statement is correct?

Tags:
Section:
Algorithm
Options:
Q5:

Consider a situation where swap operation is very costly. Which of the following sorting algorithms should be preferred so that the number of swap operations are minimized in general?

Tags:
Section:
Algorithm
Options:
Q6:

The worst case running times of Insertion sort, Merge sort and Quick sort, respectively, are:

Tags:
Section:
Algorithm
Options:
Q7:

Suppose there are 11 items in sorted order in an array. How many searches are required on the average, if binary search is employed and all searches are successful in finding the item?

Tags:
Section:
Algorithm
Options:
Q8:

Which of the following is not true about comparison based sorting algorithms?

Tags:
Section:
Algorithm
Options:
Q9:

Which of the following is not a stable sorting algorithm in its typical implementation?

Tags:
Section:
Algorithm
Options:
Q10:

What is the best time complexity of bubble sort?

Tags:
Section:
Algorithm
Options:
Q11:

Which of the following algorithm can be used to efficiently calculate single source shortest paths in a Directed Acyclic Graph?

Tags:
Section:
Algorithm
Options:
Q12:

What is the worst case time complexity of insertion sort where position of the data to be inserted is calculated using binary search?

Tags:
Section:
Algorithm
Options:
Q13:

A graph with all vertices having equal degree is known as a __________

Tags:
Section:
Algorithm
Options:
Q14:

What is the number of edges present in a complete graph having n vertices?

Tags:
Section:
Algorithm
Options:
Q15:

To implement Dijkstra’s shortest path algorithm on unweighted graphs so that it runs in linear time, the data structure to be used is:

Tags:
Section:
Algorithm
Options:
Q16:

Traversal of a graph is different from tree because

Tags:
Section:
Algorithm
Options:
Q17:

When a top-down approach of dynamic programming is applied to a problem, it usually _____________

Tags:
Section:
Algorithm
Options:
Q18:

Which of the following algorithms is NOT a divide & conquer algorithm by nature?

Tags:
Section:
Algorithm
Options:
Q19:

Output of following program?

#include<stdio.h>

void print(int n)

{

if (n > 4000)

return;

printf("%d ", n);

print(2*n);

printf("%d ", n);

}

int main()

{

print(1000);

getchar();

return 0;

}

Tags:
Section:
Algorithm
Options:
Q20:

What is the correct output of the below written code?

#include <stdio.h>

void print(int n, int j)

{

if (j >= n)

return;

if (n-j > 0 && n-j >= j)

printf("%d %d\n", j, n-j);

print(n, j+1);

}

int main()

{

int n = 8;

print(n, 1);

}

Tags:
Section:
Algorithm
Options: