![](/img/trans.png)
[英]What it the Big O time complexity for findIslands ( leet code )?
[英]Big O of this short code
我需要確定此短代碼的大O:
var iterations = 0;
function operation(num){
iterations++;
if (num == 0) return 1;
return operation(Math.floor((num / 10) * 2));
}
var result = operation(1000);
alert('Result = ' + result + ', number of iterations = ' + iterations);
我想出了O(log(logN))
周圍的東西,但不確定。 你能幫我一下嗎?
[評論意見]
~log5(N)
迭代,這意味着O(log(N))
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.