diff --git a/searching/Fibonacci_search.cpp b/searching/Fibonacci_search.cpp new file mode 100644 index 00000000..aff4c6e3 --- /dev/null +++ b/searching/Fibonacci_search.cpp @@ -0,0 +1,70 @@ +#include + +using namespace std; + +int main(){ + int arr[100],n,fm,fm1,fm2,i,l; + cout<<"enter size of array"; + cin>>n; + cout<<"enter elements"; + for(i=0;i>arr[i]; + int s; + cout<<"enter searched element"; + cin>>s; + fm1=1; + fm2=0; + fm=fm1+fm2; + while(fml) + i=l; + else + { + i=n; + } + if(arr[i]==s) + { + cout<<"element found at index "<s) + { + fm=fm2; + fm1=fm1-fm; + fm2=fm-fm1; + co+=1; + } + else + { + fm=fm1; + fm1=fm2; + fm2=fm-fm1; + offset=i; + co+=1; + } + } + if(arr[0]==s) + { + cout<<"found at index 0"; + flag=1; + } + if(flag==0) + { + cout<<"elem not fnd"; + } + +} +