From 5181843c25e8fab57c5b6db0002cf031f4811018 Mon Sep 17 00:00:00 2001 From: ankur <19280055+ank5536@users.noreply.github.com> Date: Thu, 14 Feb 2019 05:09:07 +0530 Subject: [PATCH] Add a gif showing binary search and linear search (#32384) --- .../english/algorithms/search-algorithms/binary-search/index.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/guide/english/algorithms/search-algorithms/binary-search/index.md b/guide/english/algorithms/search-algorithms/binary-search/index.md index 925156eab2..859048a3ab 100644 --- a/guide/english/algorithms/search-algorithms/binary-search/index.md +++ b/guide/english/algorithms/search-algorithms/binary-search/index.md @@ -17,6 +17,8 @@ Because we know that names in the phonebook are sorted alphabetically, we could 3. Otherwise, throw away the half of the phonebook that does not contain the name 4. Repeat until you find the name or there are no more pages left in the phonebook +[![Binary vs Linear Search](https://www.mathwarehouse.com/programming/images/binary-vs-linear-search/binary-and-linear-search-animations.gif)] + Time complexity: As we dispose off one part of the search case during every step of binary search, and perform the search operation on the other half, this results in a worst case time complexity of *O*(*log2N*). The best case occurs when the element to be found is in the middle of the list. The best case time complexity is *O*(*1*).