Skip to content

Category Archives: Algorithms Quiz

What is the best case complexity for shell sort? (A) O(1) (B) O(n) (C) O(logn) (D) O(n logn) Answer: (B) Explanation: Quiz of this QuestionPlease… Read More
What is the worst case performance for bucket sort? (A) O(n) (B) O(n logn) (C) O(n^2) (D) O(1) Answer: (C) Explanation: Quiz of this QuestionPlease… Read More
Assume that we use Bubble Sort to sort n distinct elements in ascending order. When does the best case of Bubble Sort occur? (A) When… Read More
#include<stdio.h> void crazy(int n,int a,int b) {     if (n <= 0)  return;     crazy(n-1, a, b+n);     printf("%d %d %d\n",n,a,b);     crazy(n-1, b, a+n); }    int main()… Read More
Consider the following two functions. What are time complexities of the functions? int fun1(int n) {     if (n <= 1) return n;     return 2*fun1(n-1); }… Read More
Is the following statement valid?. Given a graph where all edges have positive weights, the shortest paths produced by Dijsktra and Bellman Ford algorithm may… Read More
Is the following statement valid?. Given a weighted graph where weights of all edges are unique (no two edge have same weights), there is always… Read More
Match the following Group A Group B a) Dijkstra's single shortest path algo p) Dynamic Programming b) Bellmen Ford's single shortest path algo q) Backtracking… Read More
Is the following statement valid about shortest paths? Given a graph, suppose we have calculated shortest path from a source to all other vertices. If… Read More
What is the return value of following function for 484? What does it to in general? bool fun(int n) {     int sum = 0;     for… Read More
If the DFS finishing time f[u] > f[v] for two vertices u and v in a directed graph G, and u and v are in… Read More
Is following statement true/false? A DFS of a directed graph always produces the same number of tree edges, i.e., independent of the order in which… Read More
Is following statement true/false If a DFS of a directed graph contains a back edge, any other DFS of the same graph will also contain… Read More
Which of the following condition is sufficient to detect cycle in a directed graph? (A) There is an edge from currently being visited node to… Read More
Given a directed graph where weight of every edge is same, we can efficiently find shortest path from a given source to destination using? (A)… Read More

Start Your Coding Journey Now!