Login
Register
Dark Mode
Brightness
Profile
Edit Profile
Messages
My favorites
My Updates
Logout
Recent questions tagged identify-function
0
votes
1
answer
31
Gate Sample Practise Questions
#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; } (a) -9 (b) 5 (c) 15 (d) 19 Need explanation stepwise for solution
#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...
Pranav Madhani
505
views
Pranav Madhani
asked
May 26, 2017
Algorithms
geeksforgeeks-test-series
recursion
identify-function
+
–
2
votes
1
answer
32
Based on GATE2005-IT-53
https://gateoverflow.in/3814/gate2005-it-53 i am confused about how the while loop breaks if a=''DBC" and b="BD"? i suppose here both occurence of B and D will have zero count in count arrray when for loop is checked. please explain?
https://gateoverflow.in/3814/gate2005-it-53i am confused about how the while loop breaks if a=''DBC" and b="BD"?i suppose here both occurence of B and D will have zero co...
nabadeep
478
views
nabadeep
asked
May 23, 2017
Algorithms
identify-function
+
–
2
votes
1
answer
33
Test by Bikram | Programming | Test 2 | Question: 9
Consider the below function: int s (int n) { if (n<=1) return 1 ; n = (n-1) * (n-1) -2 - n * n + 3*n ; s(n); printf(“%d”, n ); } What is the output if initial call is $s(6)$ ? $55555$ $11111$ $54321$ $12345$
Consider the below function:int s (int n) { if (n<=1) return 1 ; n = (n-1) * (n-1) -2 - n * n + 3*n ; s(n); printf(“%d”, n ); }What is the output if initial call is $...
Bikram
371
views
Bikram
asked
May 14, 2017
Programming in C
tbb-programming-2
identify-function
+
–
54
votes
7
answers
34
GATE CSE 2017 Set 2 | Question: 43
Consider the following snippet of a C program. Assume that swap $(\&x, \&y)$ exchanges the content of $x$ and $y$: int main () { int array[] = {3, 5, 1, 4, 6, 2}; int done =0; int i; while (done==0) { done =1; for (i=0; i<=4; i ... i-1]) { swap(&array[i], &array[i-1]); done =0; } } } printf( %d , array[3]); } The output of the program is _______
Consider the following snippet of a C program. Assume that swap $(\&x, \&y)$ exchanges the content of $x$ and $y$:int main () { int array[] = {3, 5, 1, 4, 6, 2}; int done...
Arjun
17.1k
views
Arjun
asked
Feb 14, 2017
Programming in C
gatecse-2017-set2
programming
algorithms
numerical-answers
identify-function
+
–
30
votes
11
answers
35
GATE CSE 2017 Set 2 | Question: 14
Consider the following function implemented in C: void printxy(int x, int y) { int *ptr; x=0; ptr=&x; y=*ptr; *ptr=1; printf(“%d, %d”, x, y); } The output of invoking $printxy(1,1)$ is: $0, 0$ $0, 1$ $1, 0$ $1, 1$
Consider the following function implemented in C:void printxy(int x, int y) { int *ptr; x=0; ptr=&x; y=*ptr; *ptr=1; printf(“%d, %d”, x, y); }The output of invoking $...
Madhav
9.7k
views
Madhav
asked
Feb 14, 2017
Programming in C
gatecse-2017-set2
programming-in-c
identify-function
pointers
+
–
2
votes
1
answer
36
Test by Bikram | Mock GATE | Test 3 | Question: 42
Read the below code snippet: int joo( int num ) { int result = 0 ; if ( num <= 1) return 1; else { for ( i=num; i >= 1; i - - ) { result + = joo( i / 3) ; } } return result; } When $num = 6$, the return value of the function is _____.
Read the below code snippet: int joo( int num ) { int result = 0 ; if ( num <= 1) return 1; else { for ( i=num; i >= 1; i - - ) { result + = joo( i / 3) ; } } return r...
Bikram
333
views
Bikram
asked
Feb 9, 2017
GATE
tbb-mockgate-3
programming
programming-in-c
identify-function
numerical-answers
+
–
0
votes
1
answer
37
Test by Bikram | Mock GATE | Test 3 | Question: 26
The following function finds the $GCD$ recursively. int GCD(int k, int u) { if( u = = 0 ) return k ; else return GCD( u , ____); } Fill in the blank with the most appropriate function: $k/u$ $u/k$ $u \% k$ $k \% u$
The following function finds the $GCD$ recursively. int GCD(int k, int u) { if( u = = 0 ) return k ; else return GCD( u , ____); }Fill in the blank with the most appropri...
Bikram
370
views
Bikram
asked
Feb 9, 2017
GATE
tbb-mockgate-3
programming
programming-in-c
identify-function
+
–
2
votes
3
answers
38
CMI2016-A-6
In the code fragment given below, $\mathsf{start}$ and $\mathsf{end}$ are integer values and $\mathsf{prime(x)}$ is a function that returns $\mathsf{true}$ if $\mathsf{x}$ is a prime number and $\mathsf{false}$ otherwise. i:=0; j:=0; k:=0; from (m := start; m <= end; m := m ... At the end of the loop: $k == i-j.$ $k == j-i.$ $k == -j-i.$ Depends on $\mathsf{start}$ and $\mathsf{end}$
In the code fragment given below, $\mathsf{start}$ and $\mathsf{end}$ are integer values and $\mathsf{prime(x)}$ is a function that returns $\mathsf{true}$ if $\mathsf{x}...
go_editor
624
views
go_editor
asked
Dec 30, 2016
Programming in C
cmi2016
identify-function
+
–
6
votes
1
answer
39
TIFR CSE 2016 | Part B | Question: 12
A computer program computes a function $\: f \: \{0, 1\}^* \times \{0, 1\}^* \rightarrow \{0, 1\}^*$. Suppose $f(a, b)$ ahs length $\mid b \mid ^2$, where $\mid a \mid$ and $\mid b \mid$ are the lengths of $a$ and $b$. Suppose, using this program, the following ... $n^2 < t \leq n^{\log_2 n}$ $ n^{\log_2 n} < t \leq 2^{(2n)}$ $2^{(2n)} < t$
A computer program computes a function $\: f \: \{0, 1\}^* \times \{0, 1\}^* \rightarrow \{0, 1\}^*$. Suppose $f(a, b)$ ahs length $\mid b \mid ^2$, where $\mid a \mid$ a...
go_editor
733
views
go_editor
asked
Dec 29, 2016
Algorithms
tifr2016
algorithms
identify-function
+
–
8
votes
1
answer
40
TIFR CSE 2017 | Part A | Question: 12
Consider the following program modifying an $n \times n$ square matrix $A$: for i=1 to n: for j=1 to n: temp=A[i][j]+10 A[i][j]=A[j][i] A[j][i]=temp-10 end for end for Which of the following statements about the contents of matrix $A$ at the end of ... the new matrix $A$ is symmetric, that is, $A[i][j]=A[j][i]$ for all $1 \leq i, j \leq n$ $A$ remains unchanged
Consider the following program modifying an $n \times n$ square matrix $A$:for i=1 to n: for j=1 to n: temp=A[i][j]+10 A[i][j]=A[j][i] A[j][i]=temp-10 end for end forWhic...
go_editor
1.4k
views
go_editor
asked
Dec 22, 2016
Algorithms
tifr2017
algorithms
identify-function
+
–
5
votes
2
answers
41
GATE CSE 1989 | Question: 8a
What is the output produced by the following program, when the input is "HTGATE" Function what (s:string): string; var n:integer; begin n = s.length if n <= 1 then what := s else what :=contact (what (substring (s, 2, n)), s.C [1]) end; Note ... $s_{2}$ - length obtained by concatenating $s_{1}$ with $s_{2}$ such that $s_{1}$ precedes $s_{2}$.
What is the output produced by the following program, when the input is "HTGATE"Function what (s:string): string; var n:integer; begin n = s.length if n <= 1 then what :=...
makhdoom ghaya
1.3k
views
makhdoom ghaya
asked
Dec 3, 2016
Algorithms
gate1989
descriptive
algorithms
identify-function
+
–
13
votes
3
answers
42
GATE CSE 1990 | Question: 11b
The following program computes values of a mathematical function $f(x)$. Determine the form of $f(x)$. main () { int m, n; float x, y, t; scanf ("%f%d", &x, &n); t = 1; y = 0; m = 1; do { t *= (-x/m); y += t; } while (m++ < n); printf ("The value of y is %f", y); }
The following program computes values of a mathematical function $f(x)$. Determine the form of $f(x)$.main () { int m, n; float x, y, t; scanf ("%f%d", &x, &n); t = 1; y ...
makhdoom ghaya
2.1k
views
makhdoom ghaya
asked
Nov 25, 2016
Algorithms
gate1990
descriptive
algorithms
identify-function
+
–
11
votes
2
answers
43
GATE Overflow | Programming | Test 1 | Question: 13
What is the following function doing? unsigned int foo(unsigned int x) { unsigned int c = sizeof x; c <<= 3; if(x == 0) return c; c--; while(x = x & x-1) c--; return c; } Counting the number ... the number of set bits in the binary representation of x Counting the number of unset bits in the binary representation of x None of the above
What is the following function doing?unsigned int foo(unsigned int x) { unsigned int c = sizeof x; c <<= 3; if(x == 0) return c; c ; while(x = x & x-1) c ; return c; }Cou...
Arjun
1.8k
views
Arjun
asked
Oct 18, 2016
Programming in C
go-programming-1
programming
identify-function
+
–
5
votes
3
answers
44
GATE Overflow | Programming | Test 1 | Question: 4
Consider the following C functions: int f1(int a, int b) { while (a != b) { if(a > b) a = a - b; else b = b - a; } return a; } int f2(int a, int b) { while (b != 0) { int t = b; ... for all positive inputs but not f3 For some positive input all 3 functions return different values f2 and f3 return same value for all positive inputs but not f1
Consider the following C functions:int f1(int a, int b) { while (a != b) { if(a b) a = a - b; else b = b - a; } return a; } int f2(int a, int b) { while (b != 0) { int t...
Arjun
2.5k
views
Arjun
asked
Oct 18, 2016
Programming in C
go-programming-1
programming
programming-in-c
identify-function
+
–
2
votes
1
answer
45
Explain how it comes ??? # Algo.
Consider the following code: int P=0; for (i=1; i<2n; i++) { for (j=1; j<=n; j++) { if (j<i) P =P+1; } } printf(“%d”, P); What is the output printed by the above code in terms of n
Consider the following code:int P=0; for (i=1; i<2n; i++) { for (j=1; j<=n; j++) { if (j<i) P =P+1; } } printf(“%d”, P);What is the output printed by the above code i...
Çșȇ ʛấẗẻ
394
views
Çșȇ ʛấẗẻ
asked
Aug 28, 2016
Algorithms
algorithms
identify-function
output
+
–
5
votes
5
answers
46
ISRO2011-40
Consider the following pseudocode x:=1; i:=1; while ( x <= 500) begin x:=2^x; i:=i+1; end What is the value of $\textsf{i}$ at the end of the pseudocode? $4$ $5$ $6$ $7$
Consider the following pseudocodex:=1; i:=1; while ( x <= 500) begin x:=2^x; i:=i+1; endWhat is the value of $\textsf{i}$ at the end of the pseudocode?$4$$5$$6$$7$
go_editor
5.1k
views
go_editor
asked
Jun 22, 2016
Algorithms
isro2011
algorithms
identify-function
+
–
6
votes
1
answer
47
ISRO2008-69
What is the value of $F(4)$ using the following procedure: function F(K : integer) integer; begin if (k<3) then F:=k else F:=F(k-1)*F(k-2)+F(k-3) end; $5$ $6$ $7$ $8$
What is the value of $F(4)$ using the following procedure:function F(K : integer) integer; begin if (k<3) then F:=k else F:=F(k-1)*F(k-2)+F(k-3) end;$5$$6$$7$$8$
go_editor
3.2k
views
go_editor
asked
Jun 13, 2016
Algorithms
isro2008
algorithms
recursion
identify-function
+
–
5
votes
3
answers
48
ISRO2007-23
Study the following program //precondition: x>=0 public void demo(int x) { System.out.print(x % 10); if (x % 10 != 0) { demo(x/10); } System.out.print(x%10); } Which of the following is printed as a result of the call demo $(1234)$? $1441$ $3443$ $12344321$ $43211234$
Study the following program//precondition: x>=0 public void demo(int x) { System.out.print(x % 10); if (x % 10 != 0) { demo(x/10); } System.out.print(x%10); }Which of the...
go_editor
3.7k
views
go_editor
asked
Jun 10, 2016
Algorithms
isro2007
algorithms
identify-function
+
–
0
votes
1
answer
49
IISC-CSA-Research-Test-4
What is the output of the following program? int main() { int i=0; do { if (i >=5) { i+=2; printf("%d \n", i); break; } else { printf("%d \n", ++i); continue; } } while (i<7); }
What is the output of the following program?int main() { int i=0; do { if (i >=5) { i+=2; printf("%d \n", i); break; } else { printf("%d \n", ++i); continue; } } while (i...
go_editor
433
views
go_editor
asked
Jun 7, 2016
Algorithms
iisccsaresearch2016
descriptive
algorithms
identify-function
iisc-interview
+
–
1
votes
1
answer
50
ISI2014-PCB-A-1b
Let $x, y$ be two non-negative integers $< 2^{32}$. By $x \wedge y$ we mean the integer represented by the bitwise logical $AND$ of the 32- bit binary representations of $x$ and $y$. For example, if $x = 13$ and $y = 6$, then $x \wedge y$ ... the pseudo-code for the input $x = 13$? What will be the output of the pseudo-code for an arbitrary non-negative integer $x < 2^{32}$?
Let $x, y$ be two non-negative integers $< 2^{32}$. By $x \wedge y$ we mean the integer represented by the bitwise logical $AND$ of the 32- bit binary representations of ...
go_editor
505
views
go_editor
asked
May 30, 2016
Algorithms
descriptive
isi2014
algorithms
identify-function
+
–
1
votes
1
answer
51
CMI2011-B-07b
A finite sequence of bits is represented as a list with values from the set $\{0,1\}$-for example, $[0,1,0], [1,0,1,1], \dots [ \: ]$ denotes the empty list, and $[b]$ is the list consisting of one bit $b$. For a nonempty list $l, \text{ head}(l)$ returns the first ... g2(n) if (n == 0) then return(0) else return f2(g2(n-1),g1(n)) endif What is the value of $g2(256)$ and $g2(257)$?
A finite sequence of bits is represented as a list with values from the set $\{0,1\}$—for example, $[0,1,0], [1,0,1,1], \dots[ \: ]$ denotes the empty list, and $[b]$ i...
go_editor
519
views
go_editor
asked
May 27, 2016
Algorithms
descriptive
cmi2011
algorithms
identify-function
+
–
7
votes
1
answer
52
CMI2010-B-07b
A finite sequence of bits is represented as a list with values from the set $\{0,1\}$. For example, $[0,1,0], [1,0,1,1], \dots [ \: ]$ denotes the empty list, and $[b]$ is the list consisting of one bit $b$. The function $\text{length}(l)$ ... mystery1(mystery2(s,tail(t)),mystery2(s,tail(t)))) endif Suppose $s=t=110100100$. What are the first two bits of $\text{mystery2(s,t)}$?
A finite sequence of bits is represented as a list with values from the set $\{0,1\}$. For example, $[0,1,0], [1,0,1,1], \dots [ \: ]$ denotes the empty list, and $[b]$ i...
go_editor
1.1k
views
go_editor
asked
May 27, 2016
Algorithms
descriptive
cmi2010
algorithms
identify-function
+
–
5
votes
2
answers
53
CMI2015-B-06b
Consider the code below, defining the functions $f$ and $g$: f(m, n) { if (m == 0) return n; else { q = m div 10; r = m mod 10; return f(q, 10*n + r); } } g(m, n) { if (n == 0) return m; else { q = m div 10; r = m mod 10; return g(f(f(q, 0), r), n-1); } } What does $g(m, n)$ compute, for nonnegative numbers $m$ and $n$?
Consider the code below, defining the functions $f$ and $g$:f(m, n) { if (m == 0) return n; else { q = m div 10; r = m mod 10; return f(q, 10*n + r); } } g(m, n) { if (n ...
go_editor
567
views
go_editor
asked
May 27, 2016
Algorithms
descriptive
cmi2015
algorithms
identify-function
+
–
2
votes
2
answers
54
CMI2015-B-06a
Consider the code below, defining the functions $f$ and $g$: f(m, n) { if (m == 0) return n; else { q = m div 10; r = m mod 10; return f(q, 10*n + r); } } g(m, n) { if (n == 0) return m; else { q = m div 10; r = m mod 10; return g(f(f(q, 0), r), n-1); } } Compute $g(3, 7), \: g(345, 1), \: g(345, 4) \text{ and } \: g(345, 0)$.
Consider the code below, defining the functions $f$ and $g$:f(m, n) { if (m == 0) return n; else { q = m div 10; r = m mod 10; return f(q, 10*n + r); } } g(m, n) { if (n ...
go_editor
525
views
go_editor
asked
May 27, 2016
Algorithms
descriptive
cmi2015
algorithms
identify-function
+
–
3
votes
2
answers
55
CMI2014-B-07c
Consider the code below, defining the function $A$: A(m, n, p) { if (p == 0) return m+n; else if (n == 0 && p == 1) return 0; else if (n == 0 && p == 2) return 1; else if (n == 0) return m; else return A(m, A(m,n-1,p), p-1); } Compute $A(2, 2, 3)$ and $A(2, 3, 3)$.
Consider the code below, defining the function $A$:A(m, n, p) { if (p == 0) return m+n; else if (n == 0 && p == 1) return 0; else if (n == 0 && p == 2) return 1; else if ...
go_editor
640
views
go_editor
asked
May 27, 2016
Algorithms
cmi2014
descriptive
algorithms
identify-function
+
–
3
votes
2
answers
56
CMI2014-B-07b
Consider the code below, defining the function $A$: A(m, n, p) { if (p == 0) return m+n; else if (n == 0 && p == 1) return 0; else if (n == 0 && p == 2) return 1; else if (n == 0) return m; else return A(m, A(m,n-1,p), p-1); } Express $A(m, n, 2)$ as a function of $m$ and $n$.
Consider the code below, defining the function $A$:A(m, n, p) { if (p == 0) return m+n; else if (n == 0 && p == 1) return 0; else if (n == 0 && p == 2) return 1; else if ...
go_editor
651
views
go_editor
asked
May 27, 2016
Algorithms
cmi2014
descriptive
algorithms
identify-function
+
–
3
votes
2
answers
57
CMI2014-B-07a
Consider the code below, defining the function $A$: A(m, n, p) { if (p == 0) return m+n; else if (n == 0 && p == 1) return 0; else if (n == 0 && p == 2) return 1; else if (n == 0) return m; else return A(m, A(m,n-1,p), p-1); } Express $A(m, n, 1)$ as a function of $m$ and $n$.
Consider the code below, defining the function $A$:A(m, n, p) { if (p == 0) return m+n; else if (n == 0 && p == 1) return 0; else if (n == 0 && p == 2) return 1; else if ...
go_editor
668
views
go_editor
asked
May 27, 2016
Algorithms
cmi2014
descriptive
algorithms
identify-function
+
–
3
votes
3
answers
58
CMI2014-A-03
In the code fragment on the right, start and end are integer values and $\text{prime}(x)$ is a function that returns true if $x$ is a prime number and $\text{false}$ otherwise. At the end of the loop: i := 0; j := 0; k := 0; for (m := start; m <= end; m := m+1){ k := k + m ... + m; }else{ j := j + m; } } $k < i+j$ $k = i+j$ $k > i+j$ Depends on $\text{start}$ and $\text{end}$
In the code fragment on the right, start and end are integer values and $\text{prime}(x)$ is a function that returns true if $x$ is a prime number and $\text{false}$ othe...
go_editor
917
views
go_editor
asked
May 27, 2016
Algorithms
cmi2014
algorithms
identify-function
+
–
9
votes
3
answers
59
CMI2013-A-09
The below question is based on the following program. procedure mystery (A : array [1..100] of int) int i,j,position,tmp; begin for j := 1 to 100 do position := j; for i := j to 100 do if (A[i] > A[position]) then ... A[position] := tmp; endfor end When the procedure terminates, the array A has been: Reversed Left unaltered Sorted in descending order Sorted in ascending order
The below question is based on the following program.procedure mystery (A : array [1..100] of int) int i,j,position,tmp; begin for j := 1 to 100 do position := j; for i :...
go_editor
1.1k
views
go_editor
asked
May 23, 2016
Algorithms
cmi2013
algorithms
identify-function
+
–
2
votes
1
answer
60
CMI2012-A-04
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); if (eo(a ... $a,\: b$ is $O(n)$ $O(\log \log n)$ $O(\log n)$ $O(n^{\frac{1}{2}})$
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
615
views
go_editor
asked
May 22, 2016
Algorithms
cmi2012
algorithms
identify-function
time-complexity
+
–
Page:
« prev
1
2
3
4
next »
Email or Username
Show
Hide
Password
I forgot my password
Remember
Log in
Register