What is the value of "t" ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What is the value of "t" ?

t = 0; for i=1 to n { k = n while k <> 1 { k = [ k / 2 ] t = t + 1 } }

26th Dec 2018, 12:41 PM
Roham
27 Answers
+ 5
t = floor(²log n)*n Found it :)
26th Dec 2018, 1:17 PM
ShortCode
+ 2
Ohh
26th Dec 2018, 12:48 PM
ShortCode
+ 2
What is n?
26th Dec 2018, 12:48 PM
ShortCode
+ 2
n = ?
26th Dec 2018, 12:48 PM
ShortCode
+ 1
And please specify the language.
26th Dec 2018, 12:43 PM
ShortCode
+ 1
Btw, please give the value of n
26th Dec 2018, 12:47 PM
ShortCode
+ 1
or any input?
26th Dec 2018, 12:49 PM
ShortCode
+ 1
Ok thank u
26th Dec 2018, 12:51 PM
Roham
+ 1
What do u think about (n/2)-1
26th Dec 2018, 1:02 PM
Roham
+ 1
I dont think so
26th Dec 2018, 1:09 PM
ShortCode
26th Dec 2018, 1:15 PM
ShortCode
+ 1
the "while" loop will stop only if the number "n" is a power of two, then t = n * log2 (n) if the number "n" is not a power of two, then the "while" loop will run infinitely
26th Dec 2018, 1:37 PM
Игорь Яковенко
Игорь Яковенко - avatar
0
Why dont you try it on Code playground?
26th Dec 2018, 12:42 PM
ShortCode
0
Will I get the answer?
26th Dec 2018, 12:44 PM
Roham
0
Language is c++ i think and its a test for exam, we cant use pc during it, just paper
26th Dec 2018, 12:45 PM
Roham
0
I dont know😭😭😭
26th Dec 2018, 12:47 PM
Roham
0
Its C++
26th Dec 2018, 12:47 PM
Roham
0
No n dosnt have a specific value
26th Dec 2018, 12:48 PM
Roham
0
No
26th Dec 2018, 12:49 PM
Roham
0
I didnt mean value actually
26th Dec 2018, 12:50 PM
Roham