From 17e712324a0272a54e90e6d5adab42bf32787ff6 Mon Sep 17 00:00:00 2001 From: Sameer Bhardwaj Date: Wed, 5 Dec 2018 10:02:02 +0530 Subject: [PATCH] Added best case time complexity (#25511) Added best case time complexity along with the best case condition in the time complexity section. --- .../english/algorithms/search-algorithms/binary-search/index.md | 1 + 1 file changed, 1 insertion(+) diff --git a/guide/english/algorithms/search-algorithms/binary-search/index.md b/guide/english/algorithms/search-algorithms/binary-search/index.md index b426c232b5..590852b2ee 100644 --- a/guide/english/algorithms/search-algorithms/binary-search/index.md +++ b/guide/english/algorithms/search-algorithms/binary-search/index.md @@ -18,6 +18,7 @@ Because we know that names in the phonebook are sorted alphabetically, we could 4. Repeat until you find the name or there are no more pages left in the phonebook 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*). Space complexity: Binary search takes constant or *O*(*1*) space meaning that we don't do any input size related variable defining.