formatting source-code for 153fb7b8a5

This commit is contained in:
github-actions
2020-05-30 04:02:09 +00:00
parent 92fe9495ec
commit 8a2de9842b
175 changed files with 1671 additions and 3460 deletions

View File

@@ -12,12 +12,10 @@
* \returns index where the value is found
* \returns -1 if not found
*/
int InterpolationSearch(int A[], int n, int x)
{
int InterpolationSearch(int A[], int n, int x) {
int low = 0;
int high = n - 1;
while (low <= high)
{
while (low <= high) {
int mid = low + (((high - 1) * (x - A[low])) / (A[high] - A[low]));
if (x == A[mid])
return mid; // Found x, return (exit)
@@ -31,8 +29,7 @@ int InterpolationSearch(int A[], int n, int x)
}
/** main function */
int main()
{
int main() {
int A[] = {2, 4, 5, 7, 13, 14, 15, 23};
int x = 17;