MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / leftPart

Function leftPart

CPP/Problems/BitonicArray.cpp:27–43  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25 }
26
27 int leftPart (vector<int> vect, int target, int hi) { // search element in left part
28 int lo = 0;
29 int mid = lo + (hi - lo)/2;
30 while (lo <= hi) {
31 if (vect[mid] == target) {
32 return mid;
33 }
34 else if (vect[mid] > target) {
35 hi = mid - 1;
36 }
37 else {
38 lo = mid + 1;
39 }
40 mid = lo + (hi - lo)/2;
41 }
42 return -1;
43 }
44
45 int rightPart (vector<int> vect, int target, int lo) { // search element in right part
46 int hi = vect.size()-1;

Callers 1

findElementFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected