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;
}
What is recurrence for worst case of Quick Sort and what is the time complexity in Worst case?
The worst case occur in quick sort when
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?
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?
The worst case running times of Insertion sort, Merge sort and Quick sort, respectively, are:
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?
Which of the following is not true about comparison based sorting algorithms?
Which of the following is not a stable sorting algorithm in its typical implementation?
What is the best time complexity of bubble sort?
Which of the following algorithm can be used to efficiently calculate single source shortest paths in a Directed Acyclic Graph?
What is the worst case time complexity of insertion sort where position of the data to be inserted is calculated using binary search?
A graph with all vertices having equal degree is known as a __________
What is the number of edges present in a complete graph having n vertices?
To implement Dijkstra’s shortest path algorithm on unweighted graphs so that it runs in linear time, the data structure to be used is:
Traversal of a graph is different from tree because
When a top-down approach of dynamic programming is applied to a problem, it usually _____________
Which of the following algorithms is NOT a divide & conquer algorithm by nature?
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;
}
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);
}