time complexity (loop with unknown iteration count) | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
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 Respostas
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