The Gateway to Computer Science Excellence
For all GATE CSE Questions
Toggle navigation
Facebook Login
or
Email or Username
Password
Remember
Login
Register

I forgot my password
Activity
Questions
Unanswered
Tags
Subjects
Users
Ask
Prev
Blogs
New Blog
Exams
Recent questions tagged loopinvariants
0
votes
0
answers
1
NET EXAM DEC 2018 Q89
asked
Dec 25, 2018
in
Programming
by
Sanjay Sharma
Boss
(
49.3k
points)

114
views
loopinvariants
+3
votes
1
answer
2
TIFR2019B9
Consider the following program fragment: var x, y: integer; x := 1; y := 0; while y < x do begin x := 2*x; y := y+1 end; For the above fragment , which of the following is a loop invariant ? $x=y+1$ $x=(y+1)^2$ $x=(y+1)2^y$ $x=2^y$ None of the above, since the loop does not terminate
asked
Dec 18, 2018
in
Programming
by
Arjun
Veteran
(
430k
points)

478
views
tifr2019
programming
loopinvariants
0
votes
1
answer
3
Loop Invariant CLR
What is loop invariant in general term ? PS: Insertion Sort has loop invariant . We have three things in loop invariant : a. Initialization b.Maintenance c.Termination
asked
Jun 19, 2017
in
Algorithms
by
ashwina
Active
(
1.8k
points)

133
views
algorithms
loopinvariants
+22
votes
6
answers
4
GATE2017237
Consider the C program fragment below which is meant to divide $x$ by $y$ using repeated subtractions. The variables $x$, $y$, $q$ and $r$ are all unsigned int. while (r >= y) { r=ry; q=q+1; } Which of the following conditions on the variables $x, y, q$ and $r$ before the execution of ... $(q==0) \ \&\& \ (y>0)$
asked
Feb 14, 2017
in
Programming
by
Arjun
Veteran
(
430k
points)

3.8k
views
gate20172
programming
loopinvariants
+10
votes
4
answers
5
TIFR2017B5
Consider the following psuedocode fragment, where $y$ is an integer that has been initialized. int i=1 int j=1 while (i<10): j=j*i i=i+1 if (i==y): break end if end while Consider the following statements: $(i==10)$ or $(i==y)$ If $y > 10$, ... TRUE at the end of the while loop? Choose from the following options. i only iii only ii and iii only i, ii, and iii None of the above
asked
Dec 23, 2016
in
Programming
by
jothee
Veteran
(
105k
points)

667
views
tifr2017
programming
loopinvariants
+2
votes
1
answer
6
GATE19888ii
Consider the two program segments below: for i:=1 to f(x) by 1 do S end i:=1; While i<=f(x) do S i:=i+1 end Under what conditions are these two programs equivalent? Treat $S$ as any sequence of statement and f as a function.
asked
Dec 19, 2016
in
Programming
by
jothee
Veteran
(
105k
points)

390
views
gate1988
programming
descriptive
loopinvariants
+2
votes
1
answer
7
GATE19886ii
Below figure is the flowchart corresponding to a program to calculate the $\gcd$ of two integers, $M$ and $N$ respectively, $(M, N >0).$ Use assertions at the cut point $C_1$, $C_2$ and $C_3$ to prove that the flowchart is correct.
asked
Dec 19, 2016
in
Programming
by
jothee
Veteran
(
105k
points)

234
views
gate1988
normal
descriptive
loopinvariants
+6
votes
1
answer
8
GATE19877a
List the invariant assertions at points $A, B, C, D$ and $E$ in program given below: Program division (input, output) Const dividend = 81; divisor = 9; Var remainder, quotient:interger begin (*(dividend >= 0) AND (divisor > 0)*) remainder := dividend; quotient := ... := remainder  divisor; (*C*) end; (*D*) quotient := quotient  1; remainder := remainder + divisor; (*E*) end
asked
Nov 14, 2016
in
Programming
by
makhdoom ghaya
Boss
(
30.6k
points)

341
views
gate1987
programming
loopinvariants
+8
votes
3
answers
9
ISRO200715
Consider the following pseudocode x:=1; i:=1; while (x <= 1000) begin x:=2^x; i:=i+1; end; What is the value of i at the end of the pseudocode? 4 5 6 7
asked
Jun 10, 2016
in
Programming
by
jothee
Veteran
(
105k
points)

2.4k
views
isro2007
loopinvariants
+30
votes
7
answers
10
GATE2016235
The following function computes $X^{Y}$ for positive integers $X$ and $Y$. int exp (int X, int Y) { int res =1, a = X, b = Y; while (b != 0) { if (b % 2 == 0) {a = a * a; b = b/2; } else {res = res * a; b = b  1; } } return res; } Which one of the following conditions is TRUE ... loop? $X^{Y} = a^{b}$ $(res * a)^{Y} = (res * X)^{b}$ $X^{Y} = res * a^{b}$ $X^{Y} = (res * a)^{b}$
asked
Feb 12, 2016
in
Programming
by
Akash Kanase
Boss
(
41.9k
points)

3.4k
views
gate20162
programming
loopinvariants
normal
+16
votes
2
answers
11
TIFR2010B37
Consider the program where $a, b$ are integers with $b > 0$. x:=a; y:=b; z:=0; while y > 0 do if odd (x) then z:= z + x; y:= y  1; else y:= y % 2; x:= 2 * x; fi Invariant of the loop is a condition which is true before and after ... not terminate for some values of $a, b$ but when it does terminate, the condition $z = a * b$ will hold. The program will terminate with $z=a^{b}$
asked
Oct 10, 2015
in
Programming
by
makhdoom ghaya
Boss
(
30.6k
points)

962
views
tifr2010
programming
loopinvariants
+10
votes
2
answers
12
TIFR2010B30
Consider the following program for summing the entries of the array $b$: array $[0 .. N1]$ of integers, where $N$ is a positive integer. (The symbol '$<>$' denotes 'not equal to'). var i, s: integer; Program i:= 0; s:= 0; [*] while i <> N do s := s + b[i]; i := i + 1; ... $s = \sum\limits^{i1}_{j=0}b[j] \;\&\; 0 \leq i \leq N$
asked
Oct 8, 2015
in
Programming
by
makhdoom ghaya
Boss
(
30.6k
points)

711
views
tifr2010
programming
loopinvariants
+42
votes
6
answers
13
GATE2015133
Consider the following pseudo code, where $x$ and $y$ are positive integers. begin q := 0 r := x while r ≥ y do begin r := r  y q := q + 1 end end The post condition that needs to be satisfied after the program terminates is $\{ r = qx + y \wedge r < y\}$ $\{ x = qy + r \wedge r < y\}$ $\{ y = qx + r \wedge 0 < r < y\}$ $\{ q + 1 < r  y \wedge y > 0\}$
asked
Feb 13, 2015
in
Programming
by
makhdoom ghaya
Boss
(
30.6k
points)

3.8k
views
gate20151
programming
loopinvariants
normal
+1
vote
1
answer
14
loop invariant question
reversing the digits in a given integer to obtain a new integer letn=D1D2Dm int n,rev; rev=0; while(n>0) { rev=rev*10+n%10; n=n/10; } the loop invariant condition at the end of the i th iteration is (A) n=D1,D2,Dmi and rev=DmDm1Dmi+1 (B)n=Dmi+1Dm1Dm and rev=Dm1D2D1 (C)n!=rev (D)n1=D1D2Dm and rev=DmDm1D2D1
asked
Nov 23, 2014
in
Algorithms
by
Siramdas Vamshidhar
(
139
points)

494
views
algorithms
loopinvariants
+23
votes
4
answers
15
GATE200432
Consider the following program fragment for reversing the digits in a given integer to obtain a new integer. Let $n = d_1\, d_2\, \ldots\, d_m$ ... $n \neq \text{rev}$ $n=d_1\, d_2 \,\ldots\, d_m \qquad \mathbf{or} \qquad \text{rev} =d_m \,\ldots\, d_2\, d_1$
asked
Sep 19, 2014
in
Programming
by
Kathleen
Veteran
(
52.2k
points)

2.8k
views
gate2004
programming
loopinvariants
normal
+17
votes
3
answers
16
GATE19911,vi
Consider the following PASCAL program segment: if i mod 2 = 0 then while i >= 0 do begin i := i div 2; if i mod 2 < > 0 then i := i  1; else i := i – 2; end; An appropriate loopinvariant for the whileloop is ________
asked
Sep 12, 2014
in
Programming
by
Kathleen
Veteran
(
52.2k
points)

1.2k
views
gate1991
programming
loopinvariants
normal
To see more, click for the
full list of questions
or
popular tags
.
Quick search syntax
tags
tag:apple
author
user:martin
title
title:apple
content
content:apple
exclude
tag:apple
force match
+apple
views
views:100
score
score:10
answers
answers:2
is accepted
isaccepted:true
is closed
isclosed:true
Recent Posts
ISRO CSE 2020 PAPER ANALYSE
BARC OCES/DGFS 2020
ISI CMI PDF by GATE Overflow
Management Trainee Recruitment COAL INDIA 2020
ECIL Interview Experience
Follow @csegate
Recent questions tagged loopinvariants
Recent Blog Comments
it's depends year to year
What was the average cutoff that was maintained...
@Shivateja MST I don't think it will go high
http://univ.tifr.res.in/gs2020/Test_Results/INT_Sh...
TIFR interview shortlist is published.
50,741
questions
57,229
answers
197,977
comments
104,565
users