Login
Register
@
Dark Mode
Profile
Edit my Profile
Messages
My favorites
Register
Activity
Q&A
Questions
Unanswered
Tags
Subjects
Users
Ask
Previous Years
Blogs
New Blog
Exams
Dark Mode
Recent questions tagged loop-invariants
0
votes
1
answer
1
Made Easy Test Series 2024
How many times is the comparison $i >= n$ performed in the following program? int i = 200 n = 80; main() { while (i >= n) { i = i - 2 n = n + 1 } }
Ray Tomlinson
asked
in
Algorithms
Aug 9, 2023
by
Ray Tomlinson
407
views
algorithms
algorithm-design
loop-invariants
loop
time-complexity
12
votes
2
answers
2
TIFR CSE 2019 | Part B | Question: 9
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
Arjun
asked
in
Programming in C
Dec 18, 2018
by
Arjun
3.4k
views
tifr2019
programming
loop-invariants
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
dragonball
asked
in
Algorithms
Jun 19, 2017
by
dragonball
821
views
algorithms
loop-invariants
36
votes
6
answers
4
GATE CSE 2017 Set 2 | Question: 37
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=r-y; q=q+1; } Which of the following conditions on the variables $x, y, q$ and $r$ ... $(q==0) \ \&\& \ (y>0)$
Arjun
asked
in
Programming in C
Feb 14, 2017
by
Arjun
14.0k
views
gatecse-2017-set2
programming
loop-invariants
20
votes
5
answers
5
TIFR CSE 2017 | Part B | Question: 5
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 ... 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
go_editor
asked
in
Programming in C
Dec 23, 2016
by
go_editor
3.0k
views
tifr2017
programming
loop-invariants
4
votes
2
answers
6
GATE CSE 1988 | Question: 8ii
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 statements and $f$ as a function.
go_editor
asked
in
Programming in C
Dec 19, 2016
by
go_editor
2.2k
views
gate1988
programming
descriptive
loop-invariants
8
votes
1
answer
7
GATE CSE 1988 | Question: 6ii
Below figure is the flow-chart 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 flow-chart is correct.
go_editor
asked
in
Programming in C
Dec 19, 2016
by
go_editor
1.5k
views
gate1988
normal
descriptive
loop-invariants
15
votes
1
answer
8
GATE CSE 1987 | Question: 7a
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; ... = remainder - divisor; (*C*) end; (*D*) quotient := quotient - 1; remainder := remainder + divisor; (*E*) end
makhdoom ghaya
asked
in
Programming in C
Nov 14, 2016
by
makhdoom ghaya
2.4k
views
gate1987
programming
loop-invariants
descriptive
8
votes
3
answers
9
ISRO2007-15
Consider the following pseudo-code 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 pseudo-code? 4 5 6 7
go_editor
asked
in
Programming in C
Jun 10, 2016
by
go_editor
15.8k
views
isro2007
loop-invariants
49
votes
7
answers
10
GATE CSE 2016 Set 2 | Question: 35
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 ... $X^{Y} = a^{b}$ $(res * a)^{Y} = (res * X)^{b}$ $X^{Y} = res * a^{b}$ $X^{Y} = (res * a)^{b}$
Akash Kanase
asked
in
Programming in C
Feb 12, 2016
by
Akash Kanase
13.8k
views
gatecse-2016-set2
programming
loop-invariants
normal
23
votes
3
answers
11
TIFR CSE 2010 | Part B | Question: 37
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 ... 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}$
makhdoom ghaya
asked
in
Programming in C
Oct 10, 2015
by
makhdoom ghaya
3.2k
views
tifr2010
programming
loop-invariants
16
votes
2
answers
12
TIFR CSE 2010 | Part B | Question: 30
Consider the following program for summing the entries of the array $b$: array $[0 .. N-1]$ 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[ ... $s = \sum\limits^{i-1}_{j=0}b[j] \;\&\; 0 \leq i \leq N$
makhdoom ghaya
asked
in
Programming in C
Oct 8, 2015
by
makhdoom ghaya
2.7k
views
tifr2010
programming
loop-invariants
54
votes
7
answers
13
GATE CSE 2015 Set 1 | Question: 33
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\}$ ... $\{ y = qx + r \wedge 0 < r < y\}$ $\{ q + 1 < r - y \wedge y > 0\}$
makhdoom ghaya
asked
in
Programming in C
Feb 13, 2015
by
makhdoom ghaya
15.3k
views
gatecse-2015-set1
programming
loop-invariants
normal
32
votes
5
answers
14
GATE CSE 2004 | Question: 32
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$. int n, rev; rev = 0; while(n > 0) { rev = rev * 10 + n%10; n = n/10; } The loop invariant condition at the end ... $n=d_1\, d_2 \,\ldots\, d_m \qquad \mathbf{or} \qquad \text{rev} =d_m \,\ldots\, d_2\, d_1$
Kathleen
asked
in
Programming in C
Sep 19, 2014
by
Kathleen
12.0k
views
gatecse-2004
programming
loop-invariants
normal
24
votes
3
answers
15
GATE CSE 1991 | Question: 1,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 loop-invariant for the while-loop is ________
Kathleen
asked
in
Programming in C
Sep 12, 2014
by
Kathleen
4.3k
views
gate1991
programming
loop-invariants
normal
fill-in-the-blanks
To see more, click for the
full list of questions
or
popular tags
.
Subscribe to GATE CSE 2024 Test Series
Subscribe to GO Classes for GATE CSE 2024
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
Post GATE 2024 Guidance [Counseling tips and resources]
GATE CSE 2024 Result Responses
[Project Contest] Pytorch backend support for MLCommons Cpp Inference implementation
Participating in MLCommons Inference v4.0 submission (deadline is February 23 12pm IST)
IIITH PGEE 2024 Test Series by GO Classes
Subjects
All categories
General Aptitude
(3.5k)
Engineering Mathematics
(10.4k)
Digital Logic
(3.6k)
Programming and DS
(6.2k)
Algorithms
(4.8k)
Theory of Computation
(6.9k)
Compiler Design
(2.5k)
Operating System
(5.2k)
Databases
(4.8k)
CO and Architecture
(4.0k)
Computer Networks
(4.9k)
Artificial Intelligence
(79)
Machine Learning
(48)
Data Mining and Warehousing
(24)
Non GATE
(1.4k)
Others
(2.7k)
Admissions
(682)
Exam Queries
(1.6k)
Tier 1 Placement Questions
(17)
Job Queries
(80)
Projects
(11)
Unknown Category
(870)
64.3k
questions
77.9k
answers
243k
comments
79.6k
users
Recent questions tagged loop-invariants
Recent Blog Comments
Hlo I'm Rupesh I got AIR 3485 in gate CS and AIR...
@Ajay Sasank here is the direct link...
Thank you for the post didi My GATE 2023 & 2024...
I Hope it helps 😊
Today's best post I seen thank you for motivation