From 4641fc50c8a8fd19c99db439ef3c237b4f7c2e70 Mon Sep 17 00:00:00 2001 From: Leon Xu <6479451-leonxu260@users.noreply.gitlab.com> Date: Wed, 7 Jul 2021 12:15:09 -0700 Subject: [PATCH] doc: add text to binary search --- source/_posts/Binary-Search.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/source/_posts/Binary-Search.md b/source/_posts/Binary-Search.md index b01cc1f..7dc9a1d 100644 --- a/source/_posts/Binary-Search.md +++ b/source/_posts/Binary-Search.md @@ -11,4 +11,9 @@ tags: - 二分搜索(查找)是一种算法;它的输入是一个已排序的元素列表。如果你要找的元素在这个列表中,二分查找返回它所在的位置。否则,二进制搜索返回**null**。 下面的示例说明了二分查找的工作原理。我随便想一个1~100的数字。 -![二分查找工作原理](/images/Algorithms/二分查找工作原理.jpg) \ No newline at end of file +![二分查找工作原理](/images/Algorithms/二分查找工作原理.jpg) +你的目标是以最少的次数猜到这个数字。你每次猜测后,我会说小了、大了或对了。 +假设你从1开始依次往上猜,猜测过程会是这样。 +![一种糟糕的猜数法](/images/Algorithms/一种糟糕的猜数法.png) +这是简单查找,更准确的说法是*傻找*。每次猜测都只能排除一个数字。如果我想的数字是99, +你得猜99次才能猜到! \ No newline at end of file