Question: Work out what the algorithm for trinary search would look like. int binarySearch(int* arr, int lo, int hi, int value) { if (hi >= lo)

Work out what the algorithm for trinary search would look like.

int binarySearch(int* arr, int lo, int hi, int value) { if (hi >= lo) { int mid = lo + (hi - lo) / 2; if (arr[mid] == value) return mid; if (arr[mid] > value) return binarySearch(arr, lo, mid - 1, value); return binarySearch(arr, mid + 1, hi, value); } // Element not present. return -1; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!