diff --git a/TANU SINGH/Fabonacci through Recursion.cpp b/TANU SINGH/Fabonacci through Recursion.cpp new file mode 100644 index 00000000..ad7e1918 --- /dev/null +++ b/TANU SINGH/Fabonacci through Recursion.cpp @@ -0,0 +1,20 @@ +#include +using namespace std; + +int fib (int n) +{ + if (n==0 || n==1) + return n; + + else + return fib(n-1) + fib(n-2); +} + +int main() +{ + int n; + cin>>n; + cout< +using namespace std; + +bool Sorted (int arr[], int n) +{ + if(n==1) + return true; + + else + { + bool restarray = Sorted(arr+1, n-1); + return (arr[0] +using namespace std; + +int firstocc (int arr[], int n, int i, int key) +{ + if(i==n){ + return -1; + } + if(arr[i] == key){ + return i; + } + + return firstocc (arr,n,i+1,key); +} + +int lastocc (int arr[], int n, int i, int key) +{ + if(i==n){ + return -1; + } + + int restarr = lastocc(arr,n,i+1,key); + if (restarr!= -1) + return restarr; + + if(arr[i]==key) + return i; + + return -1; + +} + +int main() +{ + + int arr[] = {5,6,7,7,8}; + cout< +#include +using namespace std; + +int main() +{ + unordered_map m; + int n; + cin>>n; + + for(int i=0; i>s; + m[s]++; + } + + int q; + cin>>q; + while(q--){ + string s; + cin>>s; + cout< +using namespace std; + +int main() +{ + int n; + int sum = 0; //stores the sum of the subarray + cout<<"enter the size of the array\n"; + cin>>n; //inputing the size of the array from the array + int A[n]; + cout<<"Enter the elments of the array\n"; + + for(int i=0; i>A[i]; + } + + for(int i=0; i +using namespace std; + +void TowerOfHanoi(int n, char src, char dest, char help) +{ + + if(n==0) + return; + + TowerOfHanoi(n-1,src,help,dest); + cout<<"Move from "< +#include +using namespace std; + +int main() +{ + int n; + cin>>n; + + map m; + + for(int i=0; i>s; + m[s]++; + } + + for(auto pr:m){ + cout<