github

Made bySaurav Hathi

CSE - Mock Test - 04

Q1:

In conversion from prefix to postfix using stack data-structure, if operators and operands are pushed and popped exactly once, then the run-time complexity is −

Tags:
Section:
Algorithm
Options:
Q2:

Consider the following program fragment for reversing the digits in a given integer to obtain a new integer. Let n = D1D2…Dm

int n, rev;

rev = 0;

while (n > 0)

{

rev = rev*10 + n%10;

n = n/10;

}

The loop invariant condition at the end of the ith iteration is:

Tags:
Section:
Algorithm
Options:
Q3:

In a modified merge sort, the input array is splited at a position one-third of the length(N) of the array. What is the worst case time complexity of this merge sort?

Tags:
Section:
Algorithm
Options:
Q4:

What is a randomized Quick Sort?

Tags:
Section:
Algorithm
Options:
Q5:

Which of the following is not true about Quick Sort?

Tags:
Section:
Algorithm
Options:
Q6:

What is the best time complexity of bubble sort?

Tags:
Section:
Algorithm
Options:
Q7:

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

Tags:
Section:
Algorithm
Options:
Q8:

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?

I.   Quicksort runs in Θ(n2) time

II.  Bubblesort runs in Θ(n2) time

III. Mergesort runs in  Θ(n) time

IV.  Insertion sort runs in  Θ(n) time

Tags:
Section:
Algorithm
Options:
Q9:

Consider an array of elements arr[5]= {5,4,3,2,1} , what are the steps of insertions done while doing insertion sort in the array.

Tags:
Section:
Algorithm
Options:
Q10:

Which is the correct order of the following algorithms with respect to their time Complexity in the best case?

Tags:
Section:
Algorithm
Options:
Q11:

For the given graph(G), which of the following statements is true?

data-structure-questions-answers-graph-q3

Tags:
Section:
Algorithm
Options:
Q12:

Consider the C function given below. Assume that the array listA contains n (> 0) elements, sorted in ascending order.

int ProcessArray(int *listA, int x, int n)

{

int i, j, k;

i = 0;

j = n-1;

do

{

k = (i+j)/2;

if (x <= listA[k])

j = k-1;

if (listA[k] <= x)

i = k+1;

}

while (i <= j);

if (listA[k] == x)

return(k);

else

return -1;

}

Which one of the following statements about the function ProcessArray is CORRECT?

Tags:
Section:
Algorithm
Options:
Q13:

Which of the following condition is sufficient to detect cycle in a directed graph?

Tags:
Section:
Algorithm
Options:
Q14:

Time required to merge two sorted lists of size m and n, is

Tags:
Section:
Algorithm
Options:
Q15:

What are the appropriate data structures for following algorithms?

1) Breadth First Search

2) Depth First Search

3) Prim's Minimum Spanning Tree

4) Kruskal' Minimum Spanning Tree

Tags:
Section:
Algorithm
Options:
Q16:

Let G be an undirected graph. Consider a depth-first traversal of G, and let T be the resulting depth-first search tree. Let u be a vertex in G and let v be the first new (unvisited) vertex visited after visiting u in the traversal. Which of the following statements is always true?

Tags:
Section:
Algorithm
Options:
Q17:

Which of the following is/are property/properties of a dynamic programming problem?

Tags:
Section:
Algorithm
Options:
Q18:

Consider the same recursive C function that takes two arguments

unsigned int foo(unsigned int n, unsigned int r) {

if (n  > 0) return (n%r +  foo (n/r, r ));

else return 0;

}

What is the return value of the function foo when it is called as foo(513, 2)?

Tags:
Section:
Algorithm
Options:
Q19:

Consider the following recursive C function that takes two arguments

unsigned int foo(unsigned int n, unsigned int r) {

if (n  > 0) return (n%r +  foo (n/r, r ));

else return 0;

}

What is the return value of the function foo when it is called as foo(345, 10) ?

Tags:
Section:
Algorithm
Options:
Q20:

Which of the following is correct recurrence for worst case of Binary Search?

Tags:
Section:
Algorithm
Options: