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

Function findElement

CPP/Problems/BitonicArray.cpp:63–81  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61 }
62
63 int findElement(vector<int> vect, int size, int target) {
64 // DRIVER CODE
65 // find peak of array
66 int peak = findPeakIndex (vect, size);
67 // compare peak element with target
68 if (target > vect[peak]) {return -1;}
69 else if (target == vect[peak]) {return peak;}
70 // find element in increasing/decreasing sequence
71 else {
72 int leftIndex = leftPart(vect, target, peak);
73 if (leftIndex != -1) {
74 return leftIndex;
75 }
76 else {
77 return rightPart(vect, target, peak);
78 }
79 }
80 return 0;
81 }
82
83 int main () {
84 vector<int> numvect;

Callers 1

mainFunction · 0.85

Calls 3

findPeakIndexFunction · 0.85
leftPartFunction · 0.85
rightPartFunction · 0.85

Tested by

no test coverage detected