Merge pull request #125 from TheAlgorithms/changed_fibonacciSearch

Added some header files and changed the min() function
This commit is contained in:
Christian Bender 2018-03-20 16:41:52 +01:00 committed by GitHub
commit 2cde480dae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 9 deletions

BIN
Searches/fibonacciSearch Executable file

Binary file not shown.

View File

@ -1,3 +1,6 @@
#include <stdio.h>
#include <stdlib.h>
int fibMonaccianSearch(int arr[], int x, int n)
{
/* Initialize fibonacci numbers */
@ -23,7 +26,9 @@ int fibMonaccianSearch(int arr[], int x, int n)
while (fibM > 1)
{
// Check if fibMm2 is a valid location
int i = min(offset+fibMMm2, n-1);
// sets i to the min. of (offset+fibMMm2) and (n-1)
int i = ((offset+fibMMm2) < (n-1)) ? (offset+fibMMm2) : (n-1);
/* If x is greater than the value at index fibMm2,
cut the subarray array from offset to i */

BIN
Searches/fibonacciSearch.o Normal file

Binary file not shown.