GATE CS Asymptotic Worst Case Time and Space Complexity questions
Practise Asymptotic Worst Case Time and Space Complexity questions for GATE CS. Explore official PYQs and original topic-wise quizzes, check answers and view available solutions. Free, no sign-in.
Subject, topic, year and type filter the full library. Match any choice within a filter, and all selected filter categories. Search, source and sort apply to this page.
20 on this page
Consider the following recurrence relations: For all , Assume that for all and . Which one of the following options is correct?
Consider the recursive functions represented by the following code segment: int bar(int n) { if (n == 1) return 0; else return 1 + bar(n/2); } int foo(int n) { if (n == 1) return 1; else return 1 + foo(bar(n)); } The smallest positive integer n for which returns is . (answer in integer) Note: Ignore …
Consider the following functions, where is a positive integer. Which one of the following options lists the functions in increasing order of asymptotic growth rate? Note: Assume the base of log to be .
Which of the following can be recurrence relation(s) corresponding to an algorithm with time complexity ?
Consider an array of integers of size . The indices of run from to . An algorithm is to be designed to check whether satisfies the condition given below. such that Which one of the following gives the worst case time complexity of the fastest …
Consider the following recurrence relation: Which ONE of the following options is CORRECT?
Given an integer array of size , we want to check if the array is sorted (in either ascending or descending order). An algorithm solves this problem by making a single pass through the array and comparing each element of the array only with its adjacent elements. The worst-case time complexity of this algorithm is
Consider the following recurrence relation: Which one of the following options is CORRECT?
Let be the recurrence relation defined as follows: Which one of the following statements is TRUE?
Let and be functions of natural numbers given by and Which of the following statements is/are
Consider functions and expressed in pseudocode as follows: Function_1 while n>1 do for i=1 to n do x = x + 1; end for n = ⌊n/2⌋; end while Function_2 for i = 1 to 100 * n do x = x + 1; end for Let and denote the number of times the statement is executed in …
Which one of the following statements is for all positive functions
Consider the following three functions. Which one of the following options arranges the functions in the increasing order of asymptotic growth rate?
Consider the following recurrence relation. Which one of the following options is correct?
Consider the following function: int SimpleFunction(int Y[], int n, int x) { int total = Y[0], loopIndex; for (loopIndex=1; loopIndex<=n-1; loopIndex++) total=x*total +Y[loopIndex]; return total; } Let be an array of elements with , for all such that . The value returned …
Consider the following function: int SomeFunction (int x, int y) { if ((x==1) || (y==1)) return 1; if (x==y) return x; if (x > y) return SomeFunction(x-y, y); if (y > x) return SomeFunction (x, y-x); } The value returned by is __________
For constants and , consider the following recurrence defined on the non-negative integers: Which one of the following options is correct about the recurrence ?
Consider the following program #include <stdio.h> int foo(int x, int y, int q) { if ((x<=0) && (y<=0)) return q; if (x<=0) return foo(x, y-q, q); if (y<=0) return foo(x-q, y, q); return foo(x, y-q, q) + foo(x-q, y, q); } int main( ) { int r = foo(15, 15, 10); printf(“%d”, r); return 0; } The output of the program …
For parameters and , both of which are , , and . Then is
Consider the following C functions. int tob (int b, int* arr) { int i; for (i = 0; b>0; i++) { if (b%2) arr [i] = 1; else arr[i] = 0; b = b/2; } return (i); } int pp(int a, int b) { int arr[20]; int i, tot = 1, ex, len; ex = a; len = tob(b, arr); for (i=0; i<len ; i++) { if (arr[i] ==1) tot = tot * ex; ex= ex*ex; } return (tot) ; } The value returned …
