Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 0ecb6bd

Browse files
jiya10208realstealthninja
andauthored
docs: reword binary search (TheAlgorithms#2752)
* Update binary_search.cpp making some correction in the theory of binary search * Update search/binary_search.cpp Co-authored-by: realstealthninja <68815218+realstealthninja@users.noreply.github.com> --------- Co-authored-by: realstealthninja <68815218+realstealthninja@users.noreply.github.com>
1 parent 51be6aa commit 0ecb6bd

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

‎search/binary_search.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44
* algorithm](https://en.wikipedia.org/wiki/Binary_search_algorithm)
55
* @details
66
* Binary search is a search algorithm that finds the position of a target value
7-
* within a sorted array. Binary search compares the target value to the middle
8-
* element of the array. If they are not equal, the half in which the target
7+
* within a sorted array.Just like looking for a word in a dictionary, in binary search we compare the target value to the middle
8+
* element of the array. If they are not equal, then the half in which the target
99
* cannot lie is eliminated and the search continues on the remaining half,
1010
* again taking the middle element to compare to the target value, and repeating
1111
* this until the target value is found. If the search ends with the remaining
1212
* half being empty, the target is not in the array.
1313
*
1414
* ### Implementation
1515
*
16-
* Binary search works on sorted arrays. Binary search begins by comparing an
16+
* Binary search works on sorted arrays. It begins by comparing an
1717
* element in the middle of the array with the target value. If the target value
1818
* matches the element, its position in the array is returned. If the target
1919
* value is less than the element, the search continues in the lower half of
@@ -28,6 +28,7 @@
2828
* Worst-case time complexity O(log n)
2929
* Best-case time complexity O(1)
3030
* Average time complexity O(log n)
31+
* space complexity 0(1)
3132
* Worst-case space complexity 0(1)
3233
*
3334
* @author [Lajat Manekar](https://github.com/Lazeeez)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /