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

Function pivotIndex

CPP/recursion/pivotArray.cpp:5–18  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3using namespace std;
4
5int pivotIndex (int arr[], int lo, int hi) {
6 // base case
7 if (lo == hi) {
8 return lo;
9 }
10 int mid = lo + (hi - lo)/2;
11 // recursive relation
12 if (arr[mid] >= arr[0]) { // LINE-1
13 return pivotIndex(arr, mid+1, hi);
14 }
15 else { // LINE-2
16 return pivotIndex(arr, lo, mid);
17 }
18}
19
20int main() {
21 int array[5] = {8,10,17,1,3};

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected