Skip to content

Commit 18012a0

Browse files
KhArtNJavaenhorse
authored andcommitted
Oops, дубликация )))
1 parent ea8888d commit 18012a0

1 file changed

Lines changed: 0 additions & 54 deletions

File tree

jcf.md

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -649,60 +649,6 @@ public class Q {
649649
return index;
650650
}
651651
}
652-
653-
import java.util.HashMap;
654-
import java.util.IdentityHashMap;
655-
import java.util.Map;
656-
657-
public class Q {
658-
659-
public static void main(String[] args) {
660-
661-
Q q = new Q();
662-
q.binSearch();
663-
664-
}
665-
666-
private void binSearch() {
667-
668-
int inpArr[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
669-
670-
Integer result = binSearchF(inpArr, 1, 0, inpArr.length - 1);
671-
System.out.println("-----------------------");
672-
result = binSearchF(inpArr, 2, 0, inpArr.length - 1);
673-
674-
System.out.println("Found at position " + result);
675-
676-
}
677-
678-
private Integer binSearchF(int inpArr[], int searchValue, int low, int high) {
679-
680-
Integer index = null;
681-
while (low <= high) {
682-
System.out.println("New iteration, low = " + low + ", high = " + high);
683-
684-
int mid = (low + high) / 2;
685-
System.out.println("trying mid = " + mid + " inpArr[mid] = " + inpArr[mid]);
686-
687-
if (inpArr[mid] < searchValue) {
688-
low = mid + 1;
689-
System.out.println("inpArr[mid] (" + inpArr[mid] + ") < searchValue(" + searchValue + "), mid = " + mid
690-
+ ", setting low = " + low);
691-
} else if (inpArr[mid] > searchValue) {
692-
high = mid - 1;
693-
System.out.println("inpArr[mid] (" + inpArr[mid] + ") > searchValue(" + searchValue + "), mid = " + mid
694-
+ ", setting high = " + high);
695-
} else if (inpArr[mid] == searchValue) {
696-
index = mid;
697-
System.out.println("found at index " + mid);
698-
break;
699-
}
700-
701-
}
702-
703-
return index;
704-
}
705-
}
706652
```
707653

708654
[к оглавлению](#java-collections-framework)

0 commit comments

Comments
 (0)