| 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; |
no test coverage detected