mirror of https://github.com/TheAlgorithms/C
Merge pull request #125 from TheAlgorithms/changed_fibonacciSearch
Added some header files and changed the min() function
This commit is contained in:
commit
2cde480dae
Binary file not shown.
|
@ -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 */
|
||||
|
|
Binary file not shown.
Loading…
Reference in New Issue