time complexity (loop with unknown iteration count) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

time complexity (loop with unknown iteration count)

what is the complexity of this kind of loop: while (true){ input = integerinput limit = limitnumber if (input > limit){ print ("try again") } else { print(input) break; } }

30th Nov 2020, 10:33 AM
nrd-li4
nrd-li4 - avatar
2 Answers
30th Nov 2020, 10:37 AM
Sâñtôsh
Sâñtôsh - avatar
+ 1
As long as input is geather than limit you will stay in the loop and have to give new number. Else the input will be printed and the loop left.
30th Nov 2020, 11:48 AM
JaScript
JaScript - avatar