Login
Register
Dark Mode
Brightness
Profile
Edit Profile
Messages
My favorites
My Updates
Logout
Recent questions tagged identify-function
2
votes
1
answer
61
CMI2012-A-03
The below question is based on the following program. In the program, we assume that integer division returns only the quotient. For example $7/3$ returns $2$ since $2$ is the quotient and $1$ is the remainder. mystery(a,b){ if (b == 0) return a; if (a < b) return mystery(b,a); ... = a and (b/2)*2 < b) return 2; end; return 3; } $\text{mystery}(75,210)$ returns $2$ $6$ $10$ $15$
The below question is based on the following program. In the program, we assume that integer division returns only the quotient. For example $7/3$ returns $2$ since $2$ i...
go_editor
486
views
go_editor
asked
May 22, 2016
Algorithms
cmi2012
algorithms
identify-function
+
–
8
votes
4
answers
62
ISRO-2013-63
Consider the following $C$ code. #include <stdio.h> #include <math.h> void main () { double pi = 3.1415926535; int a = 1; int i; for (i=0; i < 3; i++) if (a = cos(pi * i/2)) printf("% d", 1); else printf("%d", 0); } What would the program print? $000$ $010$ $101$ $111$
Consider the following $C$ code.#include <stdio.h #include <math.h void main () { double pi = 3.1415926535; int a = 1; int i; for (i=0; i < 3; i++) if (a = cos(pi * i/2))...
makhdoom ghaya
6.2k
views
makhdoom ghaya
asked
May 5, 2016
Programming in C
isro2013
programming-in-c
identify-function
output
+
–
18
votes
2
answers
63
GATE CSE 2011 | Question: 49
Consider the following recursive C function that takes two arguments. unsigned int foo(unsigned int n, unsigned int r) { if (n>0) return ((n%r) + foo(n/r, r)); else return 0; } What is the return value of the function $\text{foo}$ when it is called as $\text{foo(513, 2)}$? $9$ $8$ $5$ $2$
Consider the following recursive C function that takes two arguments.unsigned int foo(unsigned int n, unsigned int r) { if (n>0) return ((n%r) + foo(n/r, r)); else return...
go_editor
5.5k
views
go_editor
asked
Apr 21, 2016
Algorithms
gatecse-2011
algorithms
recursion
identify-function
normal
+
–
0
votes
2
answers
64
What will be the output of right shift?
Consider the C function func shown below: int func(int num) { int count = 0; while (num) { count++; num>>= 1; } return (count); } The value returned by func(0235) is ________
Consider the C function func shown below: int func(int num) { int count = 0; while (num) { count++; num>>= 1; } return (count); }The value returned by func(0235) is _____...
Purple
815
views
Purple
asked
Jan 23, 2016
Programming in C
programming-in-c
identify-function
+
–
17
votes
2
answers
65
TIFR CSE 2015 | Part B | Question: 3
Consider the following code fragment in the $C$ programming language when run on a non-negative integer $n$. int f (int n) { if (n==0 || n==1) return 1; else return f (n - 1) + f(n - 2); } Assuming a typical implementation ... $n$. This algorithm runs in polynomial time in $n$ and the optimal running time is polynomial in $n$. The algorithm does not terminate.
Consider the following code fragment in the $C$ programming language when run on a non-negative integer $n$.int f (int n) { if (n==0 || n==1) return 1; else return f (n -...
makhdoom ghaya
1.8k
views
makhdoom ghaya
asked
Dec 7, 2015
Algorithms
tifr2015
algorithms
identify-function
time-complexity
+
–
1
votes
2
answers
66
Computing the value of P
Himanshu1
578
views
Himanshu1
asked
Dec 4, 2015
Algorithms
algorithms
identify-function
made-easy-test-series
+
–
40
votes
4
answers
67
TIFR CSE 2014 | Part B | Question: 20
Consider the following game. There is a list of distinct numbers. At any round, a player arbitrarily chooses two numbers $a, b$ from the list and generates a new number $c$ by subtracting the smaller number from the larger one. The numbers $a$ and $b$ are put ... $273$. What is the score of the best player for this game? $40$ $16$ $33$ $91$ $123$
Consider the following game. There is a list of distinct numbers. At any round, a player arbitrarily chooses two numbers $a, b$ from the list and generates a new number $...
makhdoom ghaya
3.2k
views
makhdoom ghaya
asked
Nov 20, 2015
Algorithms
tifr2014
algorithms
identify-function
+
–
8
votes
3
answers
68
TIFR CSE 2014 | Part B | Question: 2
Consider the following code. def brian(n): count = 0 while ( n ! = 0 ) n = n & ( n-1 ) count = count + 1 return count Here $n$ is meant to be an unsigned integer. The operator & considers its arguments in binary and ... $n$. The result depends on the number of bits used to store unsigned integers.
Consider the following code.def brian(n): count = 0 while ( n ! = 0 ) n = n & ( n-1 ) count = count + 1 return countHere $n$ is meant to be an unsigned integer. The opera...
makhdoom ghaya
2.2k
views
makhdoom ghaya
asked
Nov 19, 2015
Algorithms
tifr2014
algorithms
identify-function
+
–
12
votes
2
answers
69
TIFR CSE 2010 | Part B | Question: 24
Consider the following program operating on four variables $u, v, x, y$, and two constants $X$ and $Y$. x, y, u, v:= X, Y, Y, X; While (x ≠ y) do if (x > y) then x, v := x - y, v + u; else if (y > x) then y, u:= y ... . The program prints $\frac1 2 \times \text{gcd}(X, Y)$ followed by $\frac1 2 \times \text{lcm}(X, Y)$. The program does none of the above.
Consider the following program operating on four variables $u, v, x, y$, and two constants $X$ and $Y$.x, y, u, v:= X, Y, Y, X; While (x ≠ y) do if (x y) then x, v := ...
makhdoom ghaya
1.7k
views
makhdoom ghaya
asked
Oct 6, 2015
Algorithms
tifr2010
algorithms
identify-function
+
–
35
votes
7
answers
70
GATE CSE 2015 Set 3 | Question: 49
Suppose $c = \langle c[0], \dots, c[k-1]\rangle$ is an array of length $k$, where all the entries are from the set $\{0, 1\}$. For any positive integers $a \text{ and } n$, consider the following pseudocode. DOSOMETHING (c, a, n) $z \leftarrow 1$ ... , then the output of DOSOMETHING(c, a, n) is _______.
Suppose $c = \langle c[0], \dots, c[k-1]\rangle$ is an array of length $k$, where all the entries are from the set $\{0, 1\}$. For any positive integers $a \text{ and } n...
go_editor
7.3k
views
go_editor
asked
Feb 16, 2015
Algorithms
gatecse-2015-set3
algorithms
identify-function
normal
numerical-answers
+
–
57
votes
7
answers
71
GATE CSE 2015 Set 1 | Question: 31
Consider the following C function. int fun1 (int n) { int i, j, k, p, q = 0; for (i = 1; i < n; ++i) { p = 0; for (j = n; j > 1; j = j/2) ++p; for (k = 1; k < p; k = k * 2) ++q; } return q; } Which one of the following most closely approximates the return value of the function $\text{fun1}$? $n^3$ $n(\log n)^2$ $n \log n$ $n \log(\log n)$
Consider the following C function.int fun1 (int n) { int i, j, k, p, q = 0; for (i = 1; i < n; ++i) { p = 0; for (j = n; j 1; j = j/2) ++p; for (k = 1; k < p; k = k * 2)...
makhdoom ghaya
20.6k
views
makhdoom ghaya
asked
Feb 13, 2015
Algorithms
gatecse-2015-set1
algorithms
normal
identify-function
+
–
62
votes
12
answers
72
GATE CSE 2015 Set 2 | Question: 11
Consider the following C function. int fun(int n) { int x=1, k; if (n==1) return x; for (k=1; k<n; ++k) x = x + fun(k) * fun (n-k); return x; } The return value of $fun(5)$ is ______.
Consider the following C function.int fun(int n) { int x=1, k; if (n==1) return x; for (k=1; k<n; ++k) x = x + fun(k) * fun (n-k); return x; }The return value of $fun(5)$...
go_editor
20.9k
views
go_editor
asked
Feb 12, 2015
Algorithms
gatecse-2015-set2
algorithms
identify-function
recurrence-relation
normal
numerical-answers
+
–
25
votes
3
answers
73
GATE IT 2005 | Question: 57
What is the output printed by the following program? #include <stdio.h> int f(int n, int k) { if (n == 0) return 0; else if (n % 2) return f(n/2, 2*k) + k; else return f(n/2, 2*k) - k; } int main () { printf("%d", f(20, 1)); return 0; } $5$ $8$ $9$ $20$
What is the output printed by the following program?#include <stdio.h int f(int n, int k) { if (n == 0) return 0; else if (n % 2) return f(n/2, 2*k) + k; else return f(n/...
Ishrat Jahan
8.9k
views
Ishrat Jahan
asked
Nov 3, 2014
Algorithms
gateit-2005
algorithms
identify-function
normal
+
–
56
votes
6
answers
74
GATE IT 2005 | Question: 53
The following$ C$ function takes two ASCII strings and determines whether one is an anagram of the other. An anagram of a string s is a string obtained by permuting the letters in s. int anagram (char *a, char *b) { int count [128], j; for (j = 0; j < 128; j++) count[j] = 0; j ... [j]]++ A: count [a[j++]]++ and B: count[b[j]]-- A: count [a[j]]++ and B: count[b[j++]]--
The following$ C$ function takes two ASCII strings and determines whether one is an anagram of the other. An anagram of a string s is a string obtained by permuting the l...
Ishrat Jahan
12.0k
views
Ishrat Jahan
asked
Nov 3, 2014
Algorithms
gateit-2005
normal
identify-function
+
–
29
votes
3
answers
75
GATE IT 2004 | Question: 15
Let $x$ be an integer which can take a value of $0$ or $1$. The statement if (x == 0) x = 1; else x = 0; is equivalent to which one of the following ? $x = 1 + x;$ $x = 1 - x;$ $x = x - 1;$ $x = 1\% x;$
Let $x$ be an integer which can take a value of $0$ or $1$. The statementif (x == 0) x = 1; else x = 0;is equivalent to which one of the following ?$x = 1 + x;$$x = 1 - ...
Ishrat Jahan
9.6k
views
Ishrat Jahan
asked
Nov 1, 2014
Programming in C
gateit-2004
programming
easy
identify-function
+
–
25
votes
3
answers
76
GATE IT 2006 | Question: 52
The following function computes the value of $\binom{m}{n}$ correctly for all legal values $m$ and $n$ ($m ≥1, n ≥ 0$ and $m > n$) int func(int m, int n) { if (E) return 1; else return(func(m -1, n) + func(m - 1, n - 1)); } In the above function, which of the following is the ... $(m = = 1)$ $(n = = 0) || (m = = n)$ $(n = = 0)$ && $(m = = n)$
The following function computes the value of $\binom{m}{n}$ correctly for all legal values $m$ and $n$ ($m ≥1, n ≥ 0$ and $m n$)int func(int m, int n) { if (E) retu...
Ishrat Jahan
8.1k
views
Ishrat Jahan
asked
Oct 31, 2014
Algorithms
gateit-2006
algorithms
identify-function
normal
+
–
18
votes
3
answers
77
GATE IT 2008 | Question: 83
Consider the code fragment written in C below : void f (int n) { if (n <= 1) { printf ("%d", n); } else { f (n/2); printf ("%d", n%2); } } Which of the following implementations will produce the same output for $f(173)$ as the above code? ... { printf ("%d", n%2); f (n/2); } } Both $P1$ and $P2$ $P2$ only $P1$ only Neither $P1$ nor $P2$
Consider the code fragment written in C below : void f (int n) { if (n <= 1) { printf ("%d", n); } else { f (n/2); printf ("%d", n%2); } }Which of the following im...
Ishrat Jahan
8.7k
views
Ishrat Jahan
asked
Oct 29, 2014
Algorithms
gateit-2008
algorithms
recursion
identify-function
normal
+
–
15
votes
4
answers
78
GATE IT 2008 | Question: 82
Consider the code fragment written in C below : void f (int n) { if (n <=1) { printf ("%d", n); } else { f (n/2); printf ("%d", n%2); } } What does f(173) print? $010110101$ $010101101$ $10110101$ $10101101$
Consider the code fragment written in C below :void f (int n) { if (n <=1) { printf ("%d", n); } else { f (n/2); printf ("%d", n%2); } }What does f(173) print?$010110101$...
Ishrat Jahan
9.2k
views
Ishrat Jahan
asked
Oct 29, 2014
Algorithms
gateit-2008
algorithms
recursion
identify-function
normal
+
–
16
votes
3
answers
79
GATE CSE 1995 | Question: 4
Consider the following Pascal function where $A$ and $B$ are non-zero positive integers. What is the value of $\text{GET}(3, 2)$? function GET(A,B:integer): integer; begin if B=0 then GET:= 1 else if A < B then GET:= 0 else GET:= GET(A-1, B) + GET(A-1, B-1) end; The Pascal ... to N - 1 do for J:=1 to N do begin TMP:= A[I, J]; A[I, J]:= A[J, I]; A[J, I]:= TMP end end;
Consider the following Pascal function where $A$ and $B$ are non-zero positive integers. What is the value of $\text{GET}(3, 2)$?function GET(A,B:integer): integer; begin...
Kathleen
2.9k
views
Kathleen
asked
Oct 8, 2014
Algorithms
gate1995
algorithms
identify-function
normal
descriptive
+
–
21
votes
3
answers
80
GATE CSE 1995 | Question: 3
Consider the following high level programming segment. Give the contents of the memory locations for variables $W, X, Y$ and $Z$ after the execution of the program segment. The values of the variables $A$ and $B$ are $5CH$ and $92H$, respectively. Also indicate error conditions if ... integer is represented by two bytes) begin X :=A+B Y :=abs(A-B); W :=A-B Z :=A*B end;
Consider the following high level programming segment. Give the contents of the memory locations for variables $W, X, Y$ and $Z$ after the execution of the program segmen...
Kathleen
5.3k
views
Kathleen
asked
Oct 8, 2014
Programming in C
gate1995
programming
identify-function
descriptive
+
–
11
votes
3
answers
81
GATE CSE 1995 | Question: 2.3
Assume that $X$ and $Y$ are non-zero positive integers. What does the following Pascal program segment do? while X <> Y do if X > Y then X := X - Y else Y := Y - X; write(X); Computes the LCM of two numbers Divides the larger number by the smaller number Computes the GCD of two numbers None of the above
Assume that $X$ and $Y$ are non-zero positive integers. What does the following Pascal program segment do?while X < Y do if X Y then X := X - Y else Y := Y - X; write(X)...
Kathleen
3.6k
views
Kathleen
asked
Oct 8, 2014
Algorithms
gate1995
algorithms
identify-function
normal
+
–
21
votes
1
answer
82
GATE CSE 1995 | Question: 1.4
In the following Pascal program segment, what is the value of X after the execution of the program segment? X := -10; Y := 20; If X > Y then if X < 0 then X := abs(X) else X := 2*X; $10$ $-20$ $-10$ None
In the following Pascal program segment, what is the value of X after the execution of the program segment?X := -10; Y := 20; If X Y then if X < 0 then X := abs(X) else ...
Kathleen
3.9k
views
Kathleen
asked
Oct 8, 2014
Algorithms
gate1995
algorithms
identify-function
easy
+
–
19
votes
3
answers
83
GATE CSE 1994 | Question: 6
What function of $x$, $n$ is computed by this program? Function what(x, n:integer): integer: Var value : integer begin value := 1 if n > 0 then begin if n mod 2 =1 then value := value * x; value := value * what(x*x, n div 2); end; what := value; end;
What function of $x$, $n$ is computed by this program?Function what(x, n:integer): integer: Var value : integer begin value := 1 if n 0 then begin if n mod 2 =1 then val...
Kathleen
2.7k
views
Kathleen
asked
Oct 5, 2014
Algorithms
gate1994
algorithms
identify-function
normal
descriptive
+
–
26
votes
4
answers
84
GATE CSE 2010 | Question: 35
What is the value printed by the following C program? #include<stdio.h> int f(int *a, int n) { if (n <= 0) return 0; else if (*a % 2 == 0) return *a+f(a+1, n-1); else return *a - f(a+1, n-1); } int main() { int a[] = {12, 7, 13, 4, 11, 6}; printf("%d", f(a, 6)); return 0; } $-9$ $5$ $15$ $19$
What is the value printed by the following C program?#include<stdio.h int f(int *a, int n) { if (n <= 0) return 0; else if (*a % 2 == 0) return *a+f(a+1, n-1); else retur...
go_editor
11.6k
views
go_editor
asked
Sep 30, 2014
Algorithms
gatecse-2010
algorithms
recursion
identify-function
normal
+
–
19
votes
3
answers
85
GATE CSE 1993 | Question: 7.4
What does the following code do? var a, b: integer; begin a:=a+b; b:=a-b; a:a-b; end; exchanges $a$ and $b$ doubles $a$ and stores in $b$ doubles $b$ and stores in $a$ leaves $a$ and $b$ unchanged none of the above
What does the following code do?var a, b: integer; begin a:=a+b; b:=a-b; a:a-b; end;exchanges $a$ and $b$doubles $a$ and stores in $b$doubles $b$ and stores in $a$leaves ...
Kathleen
4.1k
views
Kathleen
asked
Sep 29, 2014
Algorithms
gate1993
algorithms
identify-function
easy
+
–
18
votes
3
answers
86
GATE CSE 2011 | Question: 48
Consider the following recursive C function that takes two arguments. unsigned int foo(unsigned int n, unsigned int r) { if (n>0) return ((n%r) + foo(n/r, r)); else return 0; } What is the return value of the function $\text{foo}$ when it is called as $\text{foo(345, 10)}$? $345$ $12$ $5$ $3$
Consider the following recursive C function that takes two arguments.unsigned int foo(unsigned int n, unsigned int r) { if (n>0) return ((n%r) + foo(n/r, r)); else return...
go_editor
8.9k
views
go_editor
asked
Sep 29, 2014
Algorithms
gatecse-2011
algorithms
recursion
identify-function
normal
+
–
36
votes
3
answers
87
GATE CSE 2014 Set 3 | Question: 10
Let $A$ be the square matrix of size $n \times n$. Consider the following pseudocode. What is the expected output? C=100; for i=1 to n do for j=1 to n do { Temp = A[i][j]+C; A[i][j] = A[j][i]; A[j][i] = ... $A$ Adding $100$ to the upper diagonal elements and subtracting $100$ from lower diagonal elements of $A$ None of the above
Let $A$ be the square matrix of size $n \times n$. Consider the following pseudocode. What is the expected output?C=100; for i=1 to n do for j=1 to n do { Temp = A[i][j]+...
go_editor
12.0k
views
go_editor
asked
Sep 28, 2014
Algorithms
gatecse-2014-set3
algorithms
identify-function
easy
+
–
27
votes
5
answers
88
GATE CSE 2014 Set 2 | Question: 10
Consider the function func shown below: int func(int num) { int count = 0; while (num) { count++; num>>= 1; } return (count); } The value returned by func($435$) is ________
Consider the function func shown below: int func(int num) { int count = 0; while (num) { count++; num>>= 1; } return (count); }The value returned by func($435$) is ______...
go_editor
11.4k
views
go_editor
asked
Sep 28, 2014
Algorithms
gatecse-2014-set2
algorithms
identify-function
numerical-answers
easy
+
–
49
votes
5
answers
89
GATE CSE 2014 Set 1 | Question: 41
Consider the following C function in which size is the number of elements in the array E: int MyX(int *E, unsigned int size) { int Y = 0; int Z; int i, j, k; for(i = 0; i< size; i++) Y = Y + E[i]; for(i=0; i < size; ... in any sub-array of array E. sum of the maximum elements in all possible sub-arrays of array E. the sum of all the elements in the array E.
Consider the following C function in which size is the number of elements in the array E: int MyX(int *E, unsigned int size) { int Y = 0; int Z; int i, j, k; for(i = 0; i...
go_editor
12.4k
views
go_editor
asked
Sep 28, 2014
Algorithms
gatecse-2014-set1
algorithms
identify-function
normal
+
–
44
votes
3
answers
90
GATE CSE 2006 | Question: 53
Consider the following C-function in which $a[n]$ and $b[m]$ are two sorted integer arrays and $c[n+m]$ be another integer array, void xyz(int a[], int b [], int c []){ int i,j,k; i=j=k=0; while ((i<n) && (j<m)) if (a[i] < b[j]) c[k++] = ... $b[m-1]\leq a[i]$ if $j=m$ only (i) only (ii) either (i) or (ii) but not both neither (i) nor (ii)
Consider the following C-function in which $a[n]$ and $b[m]$ are two sorted integer arrays and $c[n+m]$ be another integer array,void xyz(int a[], int b [], int c []){ in...
Rucha Shelke
11.4k
views
Rucha Shelke
asked
Sep 26, 2014
Algorithms
gatecse-2006
algorithms
identify-function
normal
+
–
Page:
« prev
1
2
3
4
next »
Email or Username
Show
Hide
Password
I forgot my password
Remember
Log in
Register