# Category Archives: Algorithms Quiz

What is time complexity of fun()? int fun(int n) {   int count = 0;   for (int i = n; i > 0; i /= 2)… Read More
Which of the following is not true about comparison based sorting algorithms? (A) The minimum possible time complexity of a comparison based sorting algorithm is… Read More
Which of the following standard algorithms is not Dynamic Programming based. (A) Bellman–Ford Algorithm for single source shortest path (B) Floyd Warshall Algorithm for all… Read More
Which of the following algorithms is NOT a divide & conquer algorithm by nature? (A) Euclidean algorithm to compute the greatest common divisor (B) Heap… Read More
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… Read More
Given an unsorted array. The array has this property that every element in array is at most k distance from its position in sorted array… Read More
Given a sorted array of integers, what can be the minimum worst case time complexity to find ceiling of a number x in given array?… Read More
Which of the following sorting algorithms in its typical implementation gives best performance when applied on an array which is sorted or almost sorted (maximum… Read More
Which of the following is correct recurrence for worst case of Binary Search? (A) T(n) = 2T(n/2) + O(1) and T(1) = T(0) = O(1)… Read More
Which of the following is not a stable sorting algorithm in its typical implementation. (A) Insertion Sort (B) Merge Sort (C) Quick Sort (D) Bubble… Read More
Suppose we have a O(n) time algorithm that finds median of an unsorted array. Now consider a QuickSort implementation where we first find median using… Read More
What is recurrence for worst case of QuickSort and what is the time complexity in Worst case? (A) Recurrence is T(n) = T(n-2) + O(n)… Read More
What is the value of following recurrence. T(n) = 5T(n/5) + , T(1) = 1, T(0) = 0 (A) Theta (n) (B) Theta (n^2) (C)… Read More
What is the value of following recurrence. T(n) = T(n/4) + T(n/2) + cn2 T(1) = c T(0) = 0 Where c is a positive… Read More
What is the output of following program? #include <stdio.h>    void print(int n, int j) {    if (j >= n)       return;    if (n-j > 0… Read More