diff --git a/algorithm/basic_algo/binary_search/index.html b/algorithm/basic_algo/binary_search/index.html index 275531d..f2962af 100755 --- a/algorithm/basic_algo/binary_search/index.html +++ b/algorithm/basic_algo/binary_search/index.html @@ -1366,6 +1366,24 @@ + + +
  • + + + Why it works? + + + +
  • + +
  • + + + Find the insert position + + +
  • @@ -1842,6 +1860,24 @@ + + +
  • + + + Why it works? + + + +
  • + +
  • + + + Find the insert position + + +
  • @@ -1909,6 +1945,8 @@

    Introduction[1, 4, 9, 16, 25]

    最後一個例子是想跟你強調,函數也可以用二元搜尋法,例如想要找第一個 \(f(x) \ge 10\) 的整數 \(x\),我們可以用二元搜尋法找到 \(x=4\)

    +

    那麼 ['I', 'n', 't', 'e', 'r', 's', 't', 'e', 'l', 'l', 'a', 'r'] 能用二元搜尋法嗎?答案應該是不能啦,但如果你找的到一個神奇的函式 \(Magic(x)\),可以將這個序列經過映射後變成單調的,那算你厲害,但是,又要找什麼呢?

    +

    Interstellar Main Theme - Extra Extended - Soundtrack by Hans Zimmer

    Complexity

    玩過猜數字嗎?你每猜一次,我會告訴你猜的數字是太大還是太小,讓你從 \([1, 100]\) 間猜一個數字,怎麼猜會最有效率?如果你第一次就猜 \(50\),我告訴你猜的數字太大,你就可以知道答案一定在 \([1, 49]\) 之間,這樣你就可以省下一半的時間,你可以再猜 \(25\),而我告訴你猜的數字太小,那麼答案一定在 \([26, 49]\) 之間,你又省下一半的時間,這就是二元搜尋法的精神。