Movatterモバイル変換


[0]ホーム

URL:


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

Commitb8707e6

Browse files
SouravjyotiSouravrealDuYuanChao
authored
Formula to find median in Binary Search changed (TheAlgorithms#2181)
* Formula to find median in BS changed* Fixed bugs* fixed binary search bugCo-authored-by: Sourav <kalitasourav12@gmail.com.com>Co-authored-by: Du Yuanchao <shellhub.me@gmail.com>
1 parentcebd052 commitb8707e6

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

‎Searches/BinarySearch.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ private <T extends Comparable<T>> int search(T array[], T key, int left, int rig
4545
if (right <left)return -1;// this means that the key not found
4646

4747
// find median
48-
intmedian =(left +right) >>>1;
48+
intmedian =left +((right-left) >>>1);
4949
intcomp =key.compareTo(array[median]);
5050

5151
if (comp ==0) {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp