Skip to content

Tag Archives: Analysis of Algorithms

When you wish to say something but miss a few characters/words, the first response that anyone gives you is “Did you mean this?“. The same… Read More
Prerequisite: Analysis of Algorithms | Big-O analysis In the previous article, the analysis of the algorithm using Big O asymptotic notation is discussed. In this… Read More
Consider the following two functions. What are time complexities of the functions?  C int fun1(int n) {     if (n <= 1) return n;     return 2*fun1(n-1);… Read More
Consider the following function, int unknown(int n) { int i, j, k = 0; for (i = n/2; i <= n; i++) for (j =… Read More
Let s be a sorted array of n integers. Let t(n) denote the time taken for the most efficient algorithm to determined if there are… Read More
Consider the following three claims: I  where k and m are constants II    III 2^{2n+1} = O(2^n) Which of these claims is correct? (GATE CS 2003)… Read More
Consider the following functions f(n) = 3n^{\sqrt{n}} g(n) = 2^{\sqrt{n}{\log_{2}n}} h(n) = n! Which of the following is true? (GATE CS 2000)(A) h(n) is 0(f(n))(B)… Read More
In the following C function, let n >= m.  C int gcd(n, m) {     if (n % m == 0)         return m;     n = n… Read More
Consider the following functions: f(n) = 2n g(n) = n! h(n) = nlog(n) Which of the following statements about the asymptotic behavior of f(n), g(n),… Read More
What is the time complexity of Floyd–Warshall algorithm to calculate all pair shortest path in a graph with n vertices? (A) O(n2log(n)) (B) Theta(n2log(n)) (C)… Read More
What does it mean when we say that an algorithm X is asymptotically more efficient than Y? (A) X will be a better choice for… Read More
The following statement is valid. log(n!) = (n log n). (A) True (B) False Answer: (A)Explanation: Order of growth of \\log n! and n\\log n is… Read More
In a competition, four different functions are observed. All the functions use a single for loop and within the for loop, same set of statements… Read More
What is the time complexity of the below function?  C void fun(int n, int arr[]) {     int i = 0, j = 0;     for (;… Read More
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; … Read More