Recursion in 1 Shot || Beginners Guide

  Рет қаралды 189,072

CodeHelp - by Babbar

CodeHelp - by Babbar

Күн бұрын

Join Discord Server: / discord
Solutions of Problems Discussed: drive.google.c...

Пікірлер: 684
@siddharthsingh3067
@siddharthsingh3067 3 жыл бұрын
Thanks love babber Bhaiya 16:25 Tail Recursion TC: O(N) and SC: O(N) 17:36 Head Recursion TC: O(N) and SC: O(N) 21:44 TC: O(N) and SC: O(N) 30:02 Before Optimisation TC: O(2^N) and SC: O(N) Yes, It can be Optimize with Dynamic Programming and can be done with an iterative method. Code using DP: int Fibo(int n,int dp[]) { if(n
@Cricket-Memories-With-Akshay
@Cricket-Memories-With-Akshay 3 жыл бұрын
Hello Love Bhiya, errors I find after watching this video are following: 1. 16:20 Tail Recursion TC: O(n) SC: O(n) used in recursion stack 2. 17:30 Head Recursion TC: O(n) SC: O(n) used in recursion stack 3. 23:20 TC: O(n) SC: O(n) used in recursion stack 4. 30:00 Before Optimization TC: O(2^n) SC: O(n) used in recursion stack Can be optimize using DP and can be done with an iterative method. int fibonacci (int n) { int dp[n + 1]; dp[0] = 0; dp[1] = 1; for(int i = 2; i < n + 1; i++) { dp[i] = dp[i - 1] + dp[i - 2]; } return dp[n]; } TC of above code: O(n) SC of above code: O(n) - dp array 5. 39:40 TC: O(n) SC: O(n) used in recursion stack + O(1) for mapping the number to its respective names( like 4 - 'four'). Hence, effective space complexity will be O(n) where n is length of number 6. 46:50 TC: O(log(n)) 7. 54:50 TC: O(n) SC: O(n) 8. 1:02:00 TC: O(2^n) SC: O(n) 9. 1:10:00 TC: O(3^n) SC: O(n) 10. 1:15:00 TC: O(2^n) SC: O(n) 11. 1:20:00 TC: O(n*n!) SC: O(n) Thank You for this video!
@CareerEdgeLearn
@CareerEdgeLearn 3 жыл бұрын
wow, it's great finally, I get to know about all the errors
@pranav_arya
@pranav_arya 3 жыл бұрын
ye sab errors hai ya un questions ke answers hai jo bhaiya ne video me diye hai???
@shefalimishra7551
@shefalimishra7551 3 жыл бұрын
@@pranav_arya these are the answers to the problems given
@pranav_arya
@pranav_arya 3 жыл бұрын
@@shefalimishra7551 thank you
@Lakshmi_Prasanna001
@Lakshmi_Prasanna001 3 жыл бұрын
16:19 Tail recursion as the recursive function is the last thing that is executed in the function the statement are cout
@raghavarora9529
@raghavarora9529 3 жыл бұрын
16:25 Tail Recursion ( when processing comes before the recursive call ) 17:37 Head Recursion (when call comes before processing) 23:33 T.C - O(n) S.C - O(n) 30:04 T.C - O(2^n) S.C - O(n) We can optimise using iterative method (Then we can do this in linear time and no stack space required) 39:44 T.C - O(length of number) and S.C - O(length of number ) 46:54 Fast Exponentiation TC - Log(n) 54:50 T.C - O(n) S.C - O(n) 1:02:15 Subset question TC - O(2^N) SC - O(N) 1:11:10 Max 3 jump question ( TC - O(3^N) SC- O(N)) 1:15:17 Subsequence Question ( TC - O( 2^N ) SC - O(N) ) 1:26:20 Permutations (TC - O(N*Log(N)) SC - O(N) 1:31:30 Source To Destination ( TC- O(2^(n^2)) SC -O(n^2). Done Bhaiya 🔥🔥. Thank you for this Awesome Video 🎉❤️ aroraraghav008@gmail.com
@NaushadAli-uq1ss
@NaushadAli-uq1ss 3 жыл бұрын
Thank you for making search job easy
@tech_wizard9315
@tech_wizard9315 3 жыл бұрын
Please tell whether this video was helpful or not?
@NaushadAli-uq1ss
@NaushadAli-uq1ss 3 жыл бұрын
Absolutely 100
@Tusharrao34
@Tusharrao34 3 жыл бұрын
@@tech_wizard9315 bahot helpful hai bhai
@trendtidetv528
@trendtidetv528 3 жыл бұрын
mila gift card
@Live-hh6li
@Live-hh6li 3 жыл бұрын
Method to find time and space complexity of Recursion: Time complexity = No of levels of recursion tree * Work done at each level Smjhte hai Jese lo print n numbers Ab isme apn hr level p O(1) ka kam kr rhe hai Aur isme level hogi n+1 Toh iski time complexity ho gyi O(n) Thoda complex example lete hai ab Stair wala problem Isme agr apn recursion tree dekhe toh apn ek node k lie 3 recursive call kr rhe hai Mtlb ki hr level p nodes bdhte ja rhe by a factor of 3 Pehle me 1 fir 3 fir un 3 ke 9 Aur levels kitni hai? At max n And ek node p O(1) ka work hai Toh total work 1 + 3 + 9 ....... Toh iski complexity hogi O(3^n) Agr koi recursion me apn kuch choice kr rhe hai toh uski time complexity hoti hai O(choice^n) Jese agr stairs me 1 2 3 ki jagah agr sirf 1 2 hota toh complexity O(2^n) hoti Ab bat krte hai Space ki: Toh recursion me space complexity hoti hai depth of deepest recursion tree brach Smjhte hai isko Jese ki apn n number print kr rhe the Toh usme deepest tree ek hi thi Aur woh n tk ja rhi thi Isliye space hogi O(n) Thoda complex example lete hai Stair wala problem Agr usme ap hr bar 1 steps lo Toh recursion tree kafi lmbi bn jaegi Uski height hogi n joki size of stairs hai. Isliye O(n) space complexity How recursion works actually? Jb apn recursion call krte hai tb Sbse pehla joh call hota hai woh base case tk chlta rehta hai Fir woh khatam hota hai Uske bad dusra call execute hota Isliye hm space complexity ko height of deepest branch lete hai Kyoki isse jyada time hoga nhi And ek tree ka brach khatam hone k bad uska space empty ho jata hai Jisse dusre recursive calls use krte hai I think now you can answer all 11 questions which are given by bhaiya Koi doubt ho toh you can comment
@parrotsparadise3914
@parrotsparadise3914 2 жыл бұрын
I have doubt at 38:35 Jab n=0 hoga to kuch bhi nhi print hoga right??
@abhishekdhok5245
@abhishekdhok5245 3 жыл бұрын
//I hope this will helps. Correct me if I am wrong 16:20 => example of head recursion time complexity : O(n) space complexity : O(n) 23:31 : factorial program time complexity : O(n) space complexity : O(n) 30:09 => fibonacci sequence time complexity : O(2^n) => yes we can optimize this time complexity using dp as it is so many overlapping subproblems. space complexity : O(n) 38:06 => printspell time complexity : O(n) space complexity : o(2n) 44:32 => fast exponentiation time complexity : O(logn) space complexity : 0(logn) 54:48 => sorted or unsorted time complexity : O(n) space complexity : O(n) 1:00:34 => power set time complexity : O(2^n) space complexity : O(n) 1:10:24 => staircase problem time complexity : O(3^n) i am not sure space complexity : o(n) 1:14:51 => print all subsequences time complexity : O(2^n) space complexity : O(n) 1:26:31 => print all permutations time complexity : O(n*n!) => I used google to find this. space complexity : O(n) 1:29:02 => total ways to reach destination time complexity : it is also exponential but we can also solve this type of problem using bfs.. space complexity : O(n) This is my channel where I share the knowledge which I acquired during my coding journey : kzbin.info/door/lhbnKEAywXqkLkxa_23j0Q Thank You!!!.
@manjarigoyal2706
@manjarigoyal2706 2 жыл бұрын
If u are looking for dsa playlist then u came at right channel. I've watched many videos of different playlists but couldn't find that much beginner friendly videos. He has taught in a very better way.
@parikshitrathore1510
@parikshitrathore1510 3 жыл бұрын
---16:23 Tail Recursion (printing first, then Calling our Recursive Function) [T.C O(n) & S.C O(n)] ---17:37 Head Recursion ( first calling our Recursive Function And Then Printing) [T.C O(n) & S.C O(n)] ---23:22 T.C O(n) & S.C O(n) ---30:05 T.C O(2^n) & S.C O(n) Optimization Using Iteration #include using namespace std; int main() { int n; cin>>n; int num1 =0; int num2 =1; int answer =0; for ( int i = 2; i
@shefalimishra7551
@shefalimishra7551 3 жыл бұрын
16:20 Tail Recursion Time Complexity: O(n) Space Complexity: O(n) used in recursion stack 17:30 Head Recursion Time Complexity: O(n) Space Complexity: O(n) used in recursion stack 23:20 Time Complexity: O(n) Space Complexity: O(n) used in recursion stack 30:00 Before Optimization Time Complexity: O(2^n) Space Complexity: O(n) used in recursion stack Can be optimize using DP and can be done with an iterative method. int fibonacci (int n) { int dp[n + 1]; dp[0] = 0; dp[1] = 1; for(int i = 2; i < n + 1; i++) { dp[i] = dp[i - 1] + dp[i - 2]; } return dp[n]; } The above code has a space complexity of O(n) and time complexity of above code is O(n) We can further optimize it to space complexity of O(1) with the following code: int fibonacci (int n) { int a = 0; int b = 1; for(int i = 2; i < n + 1; i++) { int temp = b; b = a + b; a = temp; } return b; } 39:40 Time Complexity: O(n) Space Complexity: O(n) used in recursion stack + O(1) for mapping the number to its respective names( like 4 - 'four'). Hence, effective space complexity will be O(n) where n is length of number i.e. number of digits 46:50 Time Complexity: O(log(n)) 54:50 Time Complexity: O(n) Space Complexity: O(n) 1:02:10 Time Complexity: O(2^n) Space Complexity: O(n) 1:10:00 Time Complexity: O(3^n) Space Complexity: O(n) 1:15:00 Time Complexity: O(2^n) Space Complexity: O(n) 1:20:00 Time Complexity: O(n*n!) Space Complexity: O(n)
@axel9194
@axel9194 3 жыл бұрын
Thx and nice ,where do u learn all this
@shefalimishra7551
@shefalimishra7551 3 жыл бұрын
@@axel9194 i actually did a course from pepcoding, but gfg is the best resource to actually learn
@axel9194
@axel9194 3 жыл бұрын
@@shefalimishra7551 ok thank you
@axel9194
@axel9194 3 жыл бұрын
Do u know another method of ques 8?
@shefalimishra7551
@shefalimishra7551 3 жыл бұрын
@@axel9194 number of jumps?
@piyushsonkar564
@piyushsonkar564 3 жыл бұрын
16:22 Tail Recursion is used ( when processing comes before the recursive call ) 17:33 Head Recursion is used (when call comes before processing) 23:27 T.C - O(n) S.C - O(n) 30:09 T.C - O(2^n) S.C - O(n) We can optimize it using iterative method i.e. we can do this in linear time and hence we do not need any space 39:39 T.C - O(length of number) and S.C - O(length of number ) 46:49 Fast Exponentiation Tc - Log(n) 54:47 T.C - O(n) S.C - O(n) 1:02:17 Subset question TC - O(2^N) SC - O(N) 1:11:10 Max 3 jump ( Tc - O(3^N) SC- O(N)) 1:15:12 Subsequence Question ( Tc - O( 2^N ) SC - O(N) ) 1:26:24 Permutations (Tc - O(N*Log(N)) SC - O(N) 1:31:33 Source To Destination ( TC- O(2^(n^2)) SC -O(n^2). piyushsonkar001@gmail.com
@FarhanKhan-mv1sc
@FarhanKhan-mv1sc 2 жыл бұрын
Gift mila bhaii
@bilalahmadmujaddadi7519
@bilalahmadmujaddadi7519 3 жыл бұрын
Whenever i stuck somewhere this man comes up with the solution ❤
@AadityaVermaCS-
@AadityaVermaCS- 3 жыл бұрын
Absolutely!👍
@keshavmishra108
@keshavmishra108 3 жыл бұрын
💯
@dipanshugupta8166
@dipanshugupta8166 3 жыл бұрын
Question 1: Get Counting 16:55 Tail Recursion TC: O(N) and SC: O(N) 17:36 Head Recursion TC: O(N) and SC: O(N) Question 2: Factorial 21:44 TC: O(N) and SC: O(N) Question 3: Fibonacci 30:02 Before optimization TC: O(2^N) and SC: O(N) Optimized code: int Fibo(int n,int dp[]) { //base case if(n
@saharshbrnwl
@saharshbrnwl 3 жыл бұрын
Thanks Bhaiya it was quite helpful...❤🖤❤ Aur ye rha answers: 1) 16:21 Tail recursion 5,4,3,2,1 Time Complexity: O(n) Space Complexity: O(n) 2) 17:39 Head recursion 1,2,3,4,5 3) 23:21 Time complexity: O(n) Memory Complexity: O(n) 4) 29:50 Fibbonaci without recurssion Time complexity: O(n) using iternative method 5) 39:43 Digit_To_Spelling Time complexity: O(length of num) Space complexity: O(length of num) 6) 56:31 Exponent : Time complexity: O(n) Space complexity: O(1) 7) 1:11:10 Sorted_Or_Unsorted : Time complexity: O(n) Space complexity: O(n) 8) Subset Time complexity: O(2^n) Space complexity: O(n) 9) Stairs Time complexity: O(3^n) Space complexity: O(n) 10) 1:15:16 Subsequence: Time complexity: O(2^n) space complexity: O(n) 11) 1:26:20 Permutation:Time complexity: O(n*n!) space complexity: O(n) 12) Source_To_Destination : Time complexity: O(n*n) space complexity: O(n*n)
@amaanansari1604
@amaanansari1604 3 жыл бұрын
16:22 Tail Recursion Time Complexity: O(n) Space Complexity: O(n) 17:40 Head Recusion Time Complexity: O(n) Space Complexity: O(n) 23:20 Time Complexity: O(n) Space Complexity: O(n) 29:54 With recursion, its Time complexity would be O(n^2) and space complexity O(n) It can be done using the iterative method with Time complexity of O(n) and space complexity O(1). 39:40 Time Complexity: O(n) Space Complexity: O(n) n= length of number 46:47 Time complexity O(log(n)) 56:30 void PowerSet(char *set, int size) { unsigned int pow_size = pow(2, size); int counter, j; for(counter = 0; counter < pow_size; counter++) { for(j = 0; j < size; j++) { if(counter & (1
@shivamsahu2381
@shivamsahu2381 3 жыл бұрын
Thank You Bhaiya for making this video. this video really helped me. Here are my answers to all the questions. And Guys Please share this video to helps others people. Q1 -------------------------> 16:25 => it is a Tail recursion. because processing(work) occurs before the recursive call. TC: O(N) and SC: O(N) --> space taken by stack mem. 17:32 => it is a head recursion. because here recursive call comes before others processing in the function. TC: O(N) and SC: O(N) --> space taken by stack mem. Q2 -------------------------> 23:26 => Factorial problem TC: O(N) and SC: O(N) -->space taken by stack mem. Q3 -------------------------> 30:02 => Before Optimisation of Fibonacci Problem TC: O(2^N) and SC: O(N) -->space taken by stack mem. Yes, it can be optimized by using Dynamic Programming and iterative method. iterative method: ( TC: O(N) and SC: O(1)) int fib(int n) { int a = 0, b = 1, c; //creating a,b variable to maintain previous two fib numbers if( n == 0) return a; for(i = 2; i 39:43 T.C: O(n) and S.C: O(n) where n is the number of digits of a given number Q5 -------------------------> 41:56 => TC: O(N) and SC: O(N) 45:56 => TC: Log(N) and SC: on(N) where N is power of given number like : a^N Q6 -------------------------> 47:25 => Sorted or unsorted array problem T.C: O(n) and S.C: O(n) Q7 -------------------------> 54:58 => Subset question T.C: O(2^n) and S.C: O(n) Q8 -------------------------> 1:11:08 => jump stair problem T.C: O(3^n) and S.C: O(n) Q9 -------------------------> 1:12:03 => Subsequence problem T.C: O(2^n) and S.C: O(n) Q10 -------------------------> 1:16:15 => Parmutation problem T.C: O(n*n!) and S.C: O(string len) Q11 -------------------------> The time complexity of problem-11 recursive solution is exponential Thank you for reading my answers. Again I am saying, this video is very helpful for me. Please like, share this video to helps others people.
@tech_wizard9315
@tech_wizard9315 3 жыл бұрын
How was the video? Did this video helped you as a beginner to solve medium/hard level problem easily??
@ritikhooda3916
@ritikhooda3916 3 жыл бұрын
16:20 => example of head recursion time complexity : O(n) space complexity : O(n) 23:31 : factorial program time complexity : O(n) space complexity : O(n) 30:09 => fibonacci sequence time complexity : O(2^n) => yes we can optimize this time complexity using dp as it is so many overlapping subproblems. space complexity : O(n) 38:06 => printspell time complexity : O(n) space complexity : o(2n) 44:32 => fast exponentiation time complexity : O(logn) space complexity : 0(logn) 54:48 => sorted or unsorted time complexity : O(n) space complexity : O(n) 1:00:34 => power set time complexity : O(2^n) space complexity : O(n) 1:10:24 => staircase problem time complexity : O(3^n) i am not sure space complexity : o(n) 1:14:51 => print all subsequences time complexity : O(2^n) space complexity : O(n) 1:26:31 => print all permutations time complexity : O(n*n!) => I used google to find this. space complexity : O(n) 1:29:02 => total ways to reach destination time complexity : it is also exponential but we can also solve this type of problem using bfs.. space complexity : O(n)
@anshulsingh1265
@anshulsingh1265 3 жыл бұрын
16:25 Tail Recursion Time Complexity- O(n) Space Complexity- O(n) 17:36 Head Recursion Time Complexity- O(n) Space Complexity- O(n) 21:44 By using Dynamic Programming we can find Factorial of larger Number's Bhaiya vale code ki TC : O(N) and SC : O(N) 30:02 We can Optimize this code with Dynamic Programming and Iterative method. Bhaiya vale code ki TC :O(2^N) and SC : O(N) Code snippet of Fibbo using DP : static int Fibb(int x,int[] memo) { if(memo[x] != -1) return memo[x]; // Dynamic memory check if(x
@kinshukrajput7358
@kinshukrajput7358 3 жыл бұрын
Really Helpful
@codedotjava3461
@codedotjava3461 3 жыл бұрын
Bhai... Aap ka dhanyavaad.. 🤙🏻🤙🏻
@anshulsingh1265
@anshulsingh1265 3 жыл бұрын
No problem guy's..
@RamChoudhary
@RamChoudhary 3 жыл бұрын
16:25 tail recursion qki ye niche se upr jara h .... phle 5 print fir 4 fir 3 and so on ....
@kelvinparmar6836
@kelvinparmar6836 3 жыл бұрын
16:23 tail recursion 17:38 head recursion 23:38 time complexity o(n) Space complexity o(n) 30:07 space complexity o(1) Time complexity o(n) 39:40 space complexity o(1) Time complexity o(n)
@saifahmedkhan3456
@saifahmedkhan3456 3 жыл бұрын
16:23 Tail Recursion (bcz, we make a recursive call at the end of func.) Time and Space Complexity = O(n) 17:34 Head Recursion (bcz, we make a recursive call at the starting of func.) Time and Space Complexity = O(n) 23:22 Time and Space Complexity = O(n) 29:56 Yes, we can do with dynamic programming (Time Complexity = O(n^2) , Space Complexity = O(n)) 39:40 Time and Space complexity = O(n) 46:56 Fast Exponentiation (Time complexity = log(n)) 54:51 Time and space complexity = O(n) 1:02:15 Subset (Time complexity =O(2^n) and Space Complexity = O(n)) 1:11:09 Max 3 ( Time Complexity = O(3^n) and Space Complexity = O(n)) 1:15:19 Sub sequence ( Time Complexity = ( 2^n) and Space Complexity - O(n) ) 1:26:22 Time Complexity = O(n*Log(n)) and Space Complexity - O(N) 1:31:33 Time =O(2^(n^2)) Space Complexity =O(n^2) Homework completed Bhaiya Thank u @love Babbar bhaiya for this amazing video Your videos really help a lot. saifahmedkhan19@gmail.com
@empvaibhav9799
@empvaibhav9799 3 жыл бұрын
Q1) Tail recursion, Head recursion respectively, TC, SC =O(n) Q2) Time and Space complexity O(N). Q3) Yes using Dynamic programming we can optimize it. TC= O(2^n). SC-(N) Q4) Space complx= O(2n), Time Complex = O(n). "n=no. of digits in given number" Q5) TC and SC O(logN) Q6) TC and SC O(n) , "n=len(arr)" Q7)TC=O(2^n), sc = O(n), "n=len(arr)". Q8)TC=O(2^n), sc = O(n) , "n=no of stairs." Q9)TC=O(2^n), sc = O(n) , "n=no of characters in given word" Q10) Tc=O(n*n) sc-O(n) Q11) Tc = exponential, we can optimize it using dynamic prog or bfs will also work, sc=O(N)
@jagritaneja9096
@jagritaneja9096 3 жыл бұрын
1. When number is printing first and then next function call is made then it is tail recursion i.e at 16:20 and when numbers are printed at return time then recursion is called head recursion. The time complexity for both will be O(n) and space complexity will also be O(n) 2. 23:20 Time complexity for factorial of a number is O(n) and space complexity is also O(n)
@lokeshnegi5051
@lokeshnegi5051 3 жыл бұрын
1. 16:22 is tail recursion because first we are printing the number and then calling the function further, so we are starting from tail and going all the way to head. In tail recursion the recursive call is the last is the last statement. T.C: O(n) and S.C: O(1) 2. 17:35 is head recursion because first we are going all the way to bottom and then coming back to head. In head recursion recursive call is the first statement in the function. T.C: O(n) and S.C: O(1) 3. 23:25 T.C: O(n) and S.C: O(1) 4. 30:00 for fibonacci we can use d.p by storing the result of terms in a map we can use them directly instead of calculating them again and again. T.C : O(n) and S.C: O(1) 5. 39:50 T.C: O(n) and S.C: O(1) 6. 1:11:13 jump stairs T.C : O(2 pow(n)) S.C : O(1) 7. 1:15:17 sub sequence T.C : O(2pow(n)) S.C : O(1)
@samiryadav2310
@samiryadav2310 3 жыл бұрын
16:20 head recursion Time complexity-O(n) ,space complexity-O(n)
@abhayvaishnav
@abhayvaishnav 3 жыл бұрын
Was waiting since morning. Dhanyawad bhaiyaji
@namankumar7275
@namankumar7275 3 жыл бұрын
Thank you bhaiya for making this video now I'm champ in Recursion 😊😂. 16:21 Head Recursion or Tail recursion? Answer: It's a Tail recursion because when nothing has to be done after the recursive call that is tail recursion. Time Complexity : O(n) & Space Complexity : O(n) 17:35 Head Recursion or Tail recursion? Answer: It's a Head recursion because when something has to be done after the recursive call. Time Complexity : O(n) & Space Complexity : O(n) 23:16 Time Complexity : O(n) & Space Complexity : O(n) 30:00 By this solution the time complexity would be Tn = T(n-1) + T(n-2) + O(1) so, Time Complexity : O(2^n) & Space Complexity : O(n) Yes we can also print the fibonaaci series using iteration Example :- public static void printFibo(int n) { int n1=0,n2=1,n3,i; System.out.print(n1+" "+n2);//printing 0 and 1 for(i=2;i
@bhavyatyagi5604
@bhavyatyagi5604 3 жыл бұрын
16:22 => example of head recursion time complexity : O(n) space complexity : O(n) 23:31 : factorial program time complexity : O(n) space complexity : O(n) 30:09 => fibonacci sequence time complexity : O(2^n) space complexity : O(n) 38:06 => printspell time complexity : O(n) space complexity : o(2n) 44:32 => fast exponentiation time complexity : O(logn) space complexity : 0(logn) 54:48 => sorted or unsorted time complexity : O(n) space complexity : O(n) 1:00:34 => power set time complexity : O(2^n) space complexity : O(n) 1:10:24 => staircase problem time complexity : O(3^n) space complexity : o(n) 1:14:51 => print all subsequences time complexity : O(2^n) space complexity : O(n) 1:26:31 => print all permutations time complexity : O(n*n!) space complexity : O(n) 1:29:02 => total ways to reach destination space complexity : O(n)
@KhanSaddam
@KhanSaddam 3 жыл бұрын
16:20 Tail recursion: If the recursive call is last thing done by the function , there is no need to keep record of previous things.. public static void func(int n){ If(n==0){ return; } else{ System.out.println(n); } return func(n-1); } 17:30 Head recursion: If the recursive call is not last thing done by the function after returning back there is something to evaluate .. public static void func(int n){ If(n==0){ return; } func(n-1); System.out.println(n); }
@keshav_jha_
@keshav_jha_ 3 жыл бұрын
Finally i have completed this whole video and saare questions k answers mene notepad me likhte ja raha tha ab me yaha paste kar de raha hu. 16:24 tail recursion hai ye wala 17:35 head recursion h ye 23:32 Time Complex - O(n) S.C - O(n) 30:06 Time Complex - O(2^n) S.C - O(n) iterative method se optimize ho sakta h 39:45 Time Complex - O(length of number) and S.C - O(length of number ) 46:53 Fast Exponentiation TC - Log(n) 54:50 T.C - O(n) S.C - O(n) 1:02:15 Subset Question hai ye TC - O(2^N) SC - O(N) 1:11:10 Max 3 jump question ( TC - O (3^N) SC- O(N)) 1:15:16 Subsequence question ( TC - O ( 2^N ) SC - O(N) ) 1:26:21 Permutation (TC - O(N*Log(N)) SC - O(N) 1:31:31 Source To dstination ( TC- O(2^(n^2)) SC -O(n^2). Rcursion pura samjhane k lie thanku bhaiya; learnsmartbesmart@gmail.com
@Arunkumar-bm7kq
@Arunkumar-bm7kq 3 жыл бұрын
16:25 head recursion, time complexity:O(n) space complexity:O(n) 17:46 tail recursion, time complexity:O(n) space complexity:O(n) 23:23 for factorial tc=O(n), sc=O(n) 30:04 fibnocii tc= golden ratio /pi(n) sc=O(n)
@harshkumaryadav2458
@harshkumaryadav2458 3 жыл бұрын
Kya baat h bhaiya ...aag lga di veere ...bhaiya abhi recursion hi NH ...stack ques dp graph hash sare data structures isi style me chahiye ...mza aa RHA h ...and I am sure aapki ye style Jo Hindi wali h ye aapko ek alg level pe le jayegi
@prashantrawat5589
@prashantrawat5589 3 жыл бұрын
16;20 tail recursion Time Complexity: O(n) Space Complexity: O(n) used in recursion stack 17:30 Head Recursion Time Complexity: O(n) Space Complexity: O(n) used in recursion stack 23:20 Time Complexity: O(n) Space Complexity: O(n) used in recursion stack 30:00 Before Optimization Time Complexity: O(2^n) Space Complexity: O(n) used in recursion stack Can be optimize using DP and can be done with an iterative method. int fibonacci (int n) { int dp[n + 1]; dp[0] = 0; dp[1] = 1; for(int i = 2; i < n + 1; i++) { dp[i] = dp[i - 1] + dp[i - 2]; } return dp[n]; } The above code has a space complexity of O(n) and time complexity of above code is O(n) We can further optimize it to space complexity of O(1) with the following code: int fibonacci (int n) { int a = 0; int b = 1; for(int i = 2; i < n + 1; i++) { int temp = b; b = a + b; a = temp; } return b; } 39:40 Time Complexity: O(n) Space Complexity: O(n) used in recursion stack + O(1) for mapping the number to its respective names( like 4 - 'four'). Hence, effective space complexity will be O(n) where n is length of number i.e. number of digits 46:50 Time Complexity: O(log(n)) 54:50 Time Complexity: O(n) Space Complexity: O(n) 1:02:10 Time Complexity: O(2^n) Space Complexity: O(n) 1:10:00 Time Complexity: O(3^n) Space Complexity: O(n) 1:15:00 Time Complexity: O(2^n) Space Complexity: O(n) 1:20:00 Time Complexity: O(n*n!) Space Complexity: O(n)
@samyakjain4143
@samyakjain4143 3 жыл бұрын
16 Tail Recursion Time Complexity: O(n) Space Complexity: O(n) 17 Head Recursion Time Complexity: O(n) Space Complexity: O(n) 23 Time Complexity: O(n) Space Complexity: O(n) 30 Before Optimization Time Complexity: O(2^n) Space Complexity: O(n) used in recursion stack Can be optimize using DP and can be done with an iterative method. 39:40 Time Complexity: O(n) Space Complexity: O(n) used in recursion stack + O(1) for mapping the number to its respective names( like 4 - 'four'). Hence, effective space complexity will be O(n) where n is length of number i.e. number of digits 46:50 Time Complexity: O(log(n)) 54:50 Time Complexity: O(n) Space Complexity: O(n) 1:02:10 Time Complexity: O(2^n) Space Complexity: O(n) 1:10:00 Time Complexity: O(3^n) Space Complexity: O(n) 1:15:00 Time Complexity: O(2^n) Space Complexity: O(n) 1:20:00 Time Complexity: O(n*n!) Space Complexity: O(n)
@shikhershukla7650
@shikhershukla7650 3 жыл бұрын
16:25 (5 4 3 2 1)head recursion as the printing is done before the recursive call Time complexity - O(n) Space complexity - O(n) 17:25 (1 2 3 4 5)tail recursion as the printing is done after the recursive call Time complexity - O(n) Space complexity - O(n) 23:40 (factorial) Time complexity - O(n) Space complexity - O(n) 29:50 (fibonacci) Time complexity - O(2^n) Space complexity - O(n) We can optimize the approach(not using recursion) by storing the previous two numbers in variables and summing them to get the nth term. 39:30 (spelling numbers) Time complexity - O(n) Space complexity - O(n) 46:50 (expenontation) Time complexity - O(log n) Space complexity - O(log n) 54:50 (sorted or unsorted) Time complexity - O(n) Space complexity - O(n) for unsorted arrays calls will be less than n but this is worst case complexity that is when the array is sorted and it will traverse all n elements 1:02:30 (subset) Time complexity - O(2^n) Space complexity - O(n) the loop returns 2^n subset for every n input array afteracademy.com/blog/print-all-subsets-of-a-given-set (link to the bitmasking approach) 1:11:00 (Ways to reach Nth stair by jumps) Time complexity - O(3^n) Space complexity(n) 1:15:20 (subsequence of a string) Time complexity - O(2^n) Space complexity - O(n) This question can be done using bit masking also 1:26:25 (permutaions of a string) Time Complexity - O(n*n!) Space complexity - O(n) Thank you so much bhaiya this really helped me a lot E-mail ID - shikher.shukla02@gmail.com
@deepanshupratik2595
@deepanshupratik2595 3 жыл бұрын
spelling no don't you think 2^n hoga for fibonacci? as for 5 it will call 3 and 4 and for 4 it will call 2&3 ....every no has 2 splits....
@shikhershukla7650
@shikhershukla7650 3 жыл бұрын
@@deepanshupratik2595 Yes you're right typed n by mistake
@tusharnain6652
@tusharnain6652 3 жыл бұрын
You teach far better then Apna College C++ classes, You nailed it.
@ndroidLover
@ndroidLover 2 жыл бұрын
Dont compare as both trying best to give us best content ever
@tusharnain6652
@tusharnain6652 2 жыл бұрын
@@ndroidLover I will.
@yugch1123
@yugch1123 2 жыл бұрын
Superb bro, now having knowledge about recursions!
@nipunkumar3384
@nipunkumar3384 3 жыл бұрын
16:25 it's a tail recursion because it is calling itself from last and base case is while n==0 so moving in reverse direction and 17:36 since we can also say this as tail because we are dealing with the tail and printing from the head.
@bilalmirza7213
@bilalmirza7213 3 жыл бұрын
Printing numbers:- Starting from 1(1,2,3,4,5) Print statement is coming after recursive call or execute after recursive call this is head recursion And second one is tail recursion (5,4,3,2,1)
@anilsuyal
@anilsuyal 3 жыл бұрын
Thankyou so much bhaiya, aisi one shot videos bana do please placement point view se, kaafi acha padhate ho aap simple desi bhaasha mein😍❤
@pratyayurade3247
@pratyayurade3247 3 жыл бұрын
*Fibonacci* Yes it can be done using loop. *For Loop* Time Complexity - O(n), Space complexity - O(1) *For Recursion* Time Complexity - 2^n, Space complexity - O(n) *Code using loop* int n; cin>>n; int first=0,second=1; if(n==0) { cout
@Abhishekkumar-xd5lb
@Abhishekkumar-xd5lb 3 жыл бұрын
1> print N to 1 : Tail recursion [TC - theta(n), SC- theta(n)] print 1 to N : Head recursion [TC - theta(n), SC- theta(n)] 2> Factorial : TC- O(n), SC- O(n) 3> Fibonacci : TC- O(2^n), SC- O(n) 4> TC :O(length of n) , SC- O(length of n) 5> TC-O(log n), SC- O(n) 6> TC- O(n), SC- O(n) 7>TC- O(2^n), SC- O(n) power set using bitwise - void PowerSet(string str) { int n = str.length(); int powSize = pow(2, n); for(int counter = 0; counter < powSize; counter++) { for(int j = 0; j < n; j++) { if((counter & (1
@devenderbariya9198
@devenderbariya9198 3 жыл бұрын
1. 16:16 Tail recursion, because recursive call is after processing. Time complexity: O(n) Space complexity: O(n) 2. 17:30 Head recursion, because processing is after recursive call. Time complexity: O(n) Space complexity: O(n) 3. 23:17 Time complexity: O(n) Space complexity: O(n) 4. 29:43 Before Optimization: Time Complexity: O(2^n) Space Complexity: O(n) Can be optimized using DP and can be done with an iterative method. int fibonacci (int n) { int dp[n + 1]; dp[0] = 0; dp[1] = 1; for(int i = 2; i < n + 1; i++) { dp[i] = dp[i - 1] + dp[i - 2]; } return dp[n]; } Time Complexity of above code: O(n) Space Complexity of above code: O(n) - dp array 5. 39:38 Time Complexity: O(n) Space Complexity: O(n) used in recursion stack + O(1) for mapping the number to its respective names( like 4 - 'four'). Hence, effective space complexity will be O(n) where n is length of number 6. 46:50 Time complexity: O(log n) Space complexity :O(log n) 7. 54:45 Time Complexity: O(n) Space Complexity: O(n) 8. 1:02:00 Time Complexity: O(2^n) Space Complexity: O(n) 9. 1:11:00 Time Complexity: O(3^n) Space Complexity: O(n) 10. 1:15:17 Time Complexity: O(2^n) Space Complexity: O(n) 11. 1:26:10 Time Complexity: O(N*Log(N)) Space Complexity: O(N) 12. 1:31:20 Time Complexity: O(2^(n^2)) Space Complexity: O(n^2) devbariya602@gmail.com
@rishabhshukla9600
@rishabhshukla9600 3 жыл бұрын
Bhaiyaa kaafi sahi on-point video tha, waiting for more content!!!
@tech_wizard9315
@tech_wizard9315 3 жыл бұрын
How was the video? Did this video helped you as a beginner to solve medium/hard level problem easily??
@ksrami7067
@ksrami7067 3 жыл бұрын
Babbar bhai full DSA cource bana do maja aa gaya isme...... DSA nahi Kiya hai mene Fir bhi sab samaj aa gaya..
@deepanshupratik2595
@deepanshupratik2595 3 жыл бұрын
video gajab thi ......actually i knew recursion a little bit as I am a beginner but now i am confident about it
@tanishqchaturvedi9171
@tanishqchaturvedi9171 3 жыл бұрын
1...16:23 Tail Recursion ( Since we are printing first , then Calling our Recursive Function) [T.C O(n) & S.C O(n)] 2..17:37 Head Recursion ( Since we are first calling our Recursive Function And Then Printing) [T.C O(n) & S.C O(n)] 3..23:22 T.C O(n) & S.C O(n) 4..30:05 T.C O(2^n) & S.C O(n) Optimization Using Iteration #include using namespace std; int main() { int n; cin>>n; int n1 =0; int n2 =1; int ans =0; for ( int i = 2; i
@dineshkartik5213
@dineshkartik5213 3 жыл бұрын
Finally it came, Thank you so much ♥️
@raunak3406
@raunak3406 3 жыл бұрын
Bro I was looking for the subset question's logic. Believe me this is the best I have ever seen!!!
@nipunkumar3384
@nipunkumar3384 3 жыл бұрын
48:25 for i in range(len(num)-1): if nums[i]>nums[i-1] and i>0: array is sorted (another logic)
@NatureChampions
@NatureChampions Жыл бұрын
I solved a lot of recursion problems but I didn't understand the concept fully..but I didn't gave up...and still solving . Today after watching only 14 minutes of you video I am able to solve all the questions. Now I am thinking how silly mistakes I was doing. Actually I made it difficult for myself by knowing that recursion is very tough from most of educators. Thanks you sir.
@pratyayurade3247
@pratyayurade3247 3 жыл бұрын
*For Counting* 16:30 - Tail Recursion, Time complexity O(n), space complexity O(n) 17:35 - Head Recursion, Time complexity O(n), space complexity O(n)
@ranuchaubey90
@ranuchaubey90 3 жыл бұрын
Thank you sir, this video is really helpfull for me , sir Aise hi hr topic p videos banate rheiye so that we can improve .
@tech_wizard9315
@tech_wizard9315 3 жыл бұрын
How was the video? Did this video helped you as a beginner to solve medium/hard level problem easily??
@ranuchaubey90
@ranuchaubey90 3 жыл бұрын
Yes , as I beginner I was not confident about recursion topic , but now I can solve questions , so yeah this video was really helpful for me
@tech_wizard9315
@tech_wizard9315 3 жыл бұрын
@@ranuchaubey90 are you able to solve Hard and medium level problems easily now after seeing this video?
@pankajagrawal3329
@pankajagrawal3329 3 жыл бұрын
1.Counting a)Tail recursion Time complexity: O(n) Space Complexity: O(n) b)Head recursion Time complexity: O(n) Space Complexity: O(n) 2.Factorial Time complexity: O(n) Space Complexity: O(n) 3.Fabonacci a)Using Recursion: Time complexity: T(n)=T(n-1)+T(n-2) it increase exponentially. Space Complexity: O(n) b)Time complexity and space complexity can be optimized using Iterative method where Time complexity: O(n) Space Complexity: O(1) 4.Spelling Time complexity: O(n) Space Complexity: O(n) here, n = number of digit in 'n'. 5.Exponent a)using normal method Time complexity: O(n) Space Complexity: O(n) b)using fast exponent method Time complexity: O(log(n)) Space Complexity: O(n) 6.Sorted-Unsorted Time complexity: O(n) Space Complexity: O(n) 7.Properset Time complexity: O(2^n) Space Complexity: O(n) 8.Stair problem Time complexity: O(2^n) Space Complexity: O(n) 9.String Subsequence Time complexity: O(2^n) Space Complexity: O(n) 10.String Permutation Time complexity: O(n*n!) Space Complexity: O(n) Thank you very much bhaiya for all of this.
@prajwalgawande8066
@prajwalgawande8066 3 жыл бұрын
5,4,3,2,1=head 1,2,3,4,5.=tail factorial=> Time Complexity: O(n) Space Complexity: O(n) fibonacii=>Time Complexity: O(n) Space Complexity: O(n) num to english spelling=>Time Complexity: O(n) Space Complexity: O(n) 39:40 Time Complexity: O(n) Space Complexity: O(n) 46:50 Time Complexity: O(log(n)) 54:50 Time Complexity: O(n) Space Complexity: O(n) 1:02:10 Time Complexity: O(2^n) Space Complexity: O(n) 1:10:00 Time Complexity: O(3^n) Space Complexity: O(n) 1:15:00 Time Complexity: O(2^n) Space Complexity: O(n) 1:20:00 Time Complexity: O(n*n!) Space Complexity: O(n)
@sudhanshupandey7916
@sudhanshupandey7916 3 жыл бұрын
please make the next video on the memory and time complexity of these questions so that we can get the concept for clear that how can we find memory and time complexity more easily.
@madhavsharma2208
@madhavsharma2208 3 жыл бұрын
firsrt question - (counting) head recursion and 2nd one is tail recursion with tc -O(n),sc-O(n) second question - (Factorial) tc-O(n),sc-O(n); third question - (fiboonaci) tc - 2^n , sc- 2^n; fourth question - (exponential)tc - O(n),sc- O(n); modified exponential - tc(logn) sc - (logn); fifth question - (arraysortedornot)tc - O(n),sc-O(n); sixth question - (powerset)tc-O(2^n),sc-O(2^n); seventh question - (substring)tc-O(2^n),sc-O(2^n); eightth question - (jump) tc-O(3^n),sc-O(3^n); backtracking abhi padhi nahi bahiya
@Live-hh6li
@Live-hh6li 3 жыл бұрын
All time and space complexity: 1. Counting T. C. - O(n) S. C. - O(n) 2. Factorial T. C. - O(n) S. C. - O(n) 3. Fibonacci T. C. - O(2^n) S. C. - O(n) 4. Spell the number T. C. - O(no of digits) S. C. - O(no of digits) 5. Binary Exponentiation T. C. - O(logn) S. C. - O(logn) 6. Sorted or unsorted T. C. - O(n) S. C. - O(n) 7. PowerSet T. C. - O(2^n) S. C. - O(n) 8. Stairs T. C. - O(3^n) S. C. - O(n) 9. Subsequence T. C. - O(2^n) S. C. - O(n) 10. Permutation T. C. - O(n^2) S. C. - O(n) 11. Source to Destination T. C. - O(2^n) S. C. - O(Length of Longest Path from source to Destination)
@Live-hh6li
@Live-hh6li 3 жыл бұрын
All time and space complexities are of recursive solutions
@ashvinimeshram5242
@ashvinimeshram5242 3 жыл бұрын
16:24. Its tail recursion because it calling itself from last. 17:37. Its head recursion because call come before processing. 23:20. T.c. O(N). S.c. O(N) 30:04. Befire optimization Time complexity O(2^N) and space O(N) and we can optimise ut by doing with iterative method in O(N) time complexity. 39:40. Time complexity O(length of number) space complexity. O(length of no)
@dexter2474
@dexter2474 3 жыл бұрын
Question 1 is tail recursion , because we make the recursive call at the end of the recursive function. Another one is head recursion . Time Complexity= O(n) Space Complexity= O(n)
@bestclips512
@bestclips512 3 жыл бұрын
1)16:23 Tail Recursion ( Since we are printing first , then Calling our Recursive Function) [T.C O(n) & S.C O(n)] 2)17:37 Head Recursion ( Since we are first calling our Recursive Function And Then Printing) [T.C O(n) & S.C O(n)] 3)23:22 T.C O(n) & S.C O(n) 4)30:05 T.C O(2^n) & S.C O(n) Optimization Using Iteration #include using namespace std; int main() { clrscr(); int n ,n1=0,n2=0,ans=0,i; cin>>n; int n1 =0; for (i = 2; i
@endgame3842
@endgame3842 3 жыл бұрын
Arai bhai hamesa ki tarah hard bahoot hard bhai. u are absolutely fantastic
@shivamsinha5416
@shivamsinha5416 3 жыл бұрын
16:20 Tail recursion 17:34 Head recursion Time complexity for counting code O(N) and space complexity for counting code O(N) 21:48 for factorial of large number use long int 23:34 TC O(N) and Memory complexity O(N) 29:59 yes it can be optimised, before optimization time complexity is O(2^N) n SC O(N) but if we use dynamic programming then time complexity will be O(N) 39:40 TC O(1) n SC O(1) 54:52 TC O(N) n SC O(N) 1:02:15 TC O(2^N) n SC O(N) 1:10:10 TC O(3^N) n SC O(N) 1:15:35 TC O(2^N) n SC O(N) 1:26:20 Permutations TC O(N*Log(N)) n SC -O(N) 1:31:30 Source To Destination TC- O(2^(n^2)) n SC O(n^2).
@vikashkumarbasant8632
@vikashkumarbasant8632 3 жыл бұрын
4: Fibonacci series Recurence relation: T(n) = K+2T(n/2) Timecomplexity:O(2^n) Space complexity:O(n) But we can do iterative approach because in this case Timecomplexity:O(n) Space complexity:O(1)
@siri3359
@siri3359 3 жыл бұрын
This series of you teaching us is extremely helpful bhaiya... C++ STL, and now Recursion ... more power for your planning and efforts... Thank you sooo much
@ashik-1508
@ashik-1508 3 жыл бұрын
1. Tail Recursion 2. TC : theta(n), SC : theta(n) 3. FIb. TC : O(1.6 ^ n), SC : O(max depth of tree), fib[i] = fib[i - 1] + fib[i - 2] 4. PrintSpell TC : theta(no. of digits), SC : theta(no. of digits) 5. Exponent TC : O(log n) SC : O(log n) 6. subset TC : O(2 ^ n) SC : O(max depth of tree) 7. jumps TC : O(3 ^ n) SC : O(max depth of tree) 8. subseq. TC : O(2 ^ sizeof string) SC : O(max depth of tree) 9. permu. TC : O(N!) SC: O(N)
@rahulpatel43433
@rahulpatel43433 3 жыл бұрын
1. 16:20 Tail Recursion TC: O(n) SC: O(n) used in recursion stack 2. 17:30 Head Recursion TC: O(n) SC: O(n) used in recursion stack 3. 23:20 TC: O(n) SC: O(n) used in recursion stack 4. 30:00 Before Optimization TC: O(2^n) SC: O(n) used in recursion stack Can be optimize using DP and can be done with an iterative method. int fibonacci (int n) { int a[n + 1]; a[0] = 0; a[1] = 1; for(int i = 2; i < n + 1; i++) { a[i] = a[i - 1] + a[i - 2]; } return a[n]; } TC of above code: O(n) SC of above code: O(n) - a array 5. 39:40 TC: O(n) SC: O(n) used in recursion stack + O(1) for mapping the number to its respective names( like 4 - 'four'). Hence, effective space complexity will be O(n) where n is length of number 6. 46:50 TC: O(log(n)) 7. 54:50 TC: O(n) SC: O(n) 8. 1:02:00 TC: O(2^n) SC: O(n) 9. 1:10:00 TC: O(3^n) SC: O(n) 10. 1:15:00 TC: O(2^n) SC: O(n) 11. 1:20:00 TC: O(n*n!) SC: O(n)
@gauravbaghel1908
@gauravbaghel1908 3 жыл бұрын
Great explanation bhaiya, maza aa gya, or bhi topics pr bnao 1 shot videos ❤ i know how much time these videos take..great work
@deviltvpublication922
@deviltvpublication922 3 жыл бұрын
54321 head recursion O(n), space comp O(1) 12345 tail recursion O(n),space comp O(1) Iterative approach Fibonacci () { Int start =0,end=1; Count
@sloppybug9856
@sloppybug9856 3 жыл бұрын
30:01. Time complexity is O (n sq) because function is called 2 times at every recursion Memory complexity is O (n) the max depth of tree Yes, iterative solution is the best way because for loop is used from 2 to n Time complexity is O(n) And space is 0(1) because the result is just swaped at every loop
@triyabyadwal9567
@triyabyadwal9567 3 жыл бұрын
1. Counting problem: TC- O(n) and SC- O(1) 2. Factorial: TC- O(n) and SC- O(1) {if we don't consider stack space} **factorial can also be calculated iteratively as recursion can be costly for large numbers. 3. Fibonacci Series: TC- O(2^n) and SC- O(n) **can be optimised using dp: TC-O(n) SC-O(n) Code: int fib(int n) { int f[n+1]; int i; f[0] = 0; f[1] = 1; for (i = 2; i
@vikashkumarbasant8632
@vikashkumarbasant8632 3 жыл бұрын
1. Head recursion because we need to start with N. So we can say Head recursion . But if we want start with 1 go till N then it is tail recursion.
@mukeshupadhyay7409
@mukeshupadhyay7409 3 жыл бұрын
Bhai aaj tak itna easy explanation muje nhi mila
@ankeshmahagaonkar3249
@ankeshmahagaonkar3249 3 жыл бұрын
bhaiya bahot acha chal raaha hai , aisehi banate raho video
@punjabisongsshayri8050
@punjabisongsshayri8050 3 жыл бұрын
16:25 Tail Recursion (5, 4, 3, 2, 1) 17:39 Head Recursion (1, 2, 3, 4, 5) 17:45 Time Complexity -> O(n), Memory Complexity -> O(n) (Call Stack space) 23:20 Time Complexity -> O(n), Memory Complexity -> O(n) (Call Stack space) 30:04 Fibonaacci (Recursive) Time Complexity -> O(2^n), Memory Complexity -> O(n) (Call Stack space) Fibonaacci (iterative) Time Complexity -> O(n), Memory Complexity -> O(1) 39:45 Let n = number of digits Time Complexity -> O(n), Memory Complexity -> O(n) (Call Stack space) 41:55 Exponentiation Time Complexity -> O(n), Memory Complexity -> O(n) (Call Stack space) 46:42 Fast Exponentiation Time Complexity -> O(log(n)), Memory Complexity -> O(log(n) (Call Stack space) 54:36 Array is Sorted or Unsorted Time Complexity -> O(n), Memory Complexity -> O(n) (Call Stack space) 1:00 Subset Time Complexity -> O(2^n), Memory Complexity -> O(n) (Call Stack space) 1:11 Jumping Probl Time Complexity -> O(3^n), Memory Complexity -> O(n) (Call Stack space) 1:15 Subsequence Time Complexity -> O(2^n), Memory Complexity -> O(n) (Call Stack space) 1:26 Permutation Time Complexity -> O( n * n! ), Memory Complexity -> O(n) (Call Stack space) 1:31 Source To Destination Let x = dest_x - src_x , y = dest_y - src_y Time Complexity -> O(x * y) Let distance between src to distance is d = dest_x - src_x + dest_y - src_y Space Complexity = O(n * m) + O(d) (Call Stack space) Email - ayushkanish09@gmail.com
@vikashkumarbasant8632
@vikashkumarbasant8632 3 жыл бұрын
5: printSpelling Timecomplexity:logN (base 10) Space complexity:constant
@lakshyasoni0811
@lakshyasoni0811 3 жыл бұрын
1. Head Recursion 2. Tail Recursion 3. Space Complex. O(n), Time Complex. O(n) 4. It can be also solved using DP approach Time Complex of the code using recursion O(2^n) Space Complex. O(n)
@SURAJSINGH-to4pr
@SURAJSINGH-to4pr 3 жыл бұрын
Bhaiya....aisehi data structure ke sabhi topic ka video la dijiye please 🙏..
@jaygohel1728
@jaygohel1728 2 жыл бұрын
bhai aj Recursion padh ke maja a gaya. bahot easy hai recursion .
@agnivpal9208
@agnivpal9208 Жыл бұрын
U helped a lot for ISC 12th class coz there is very few to teach Java recursion logics properly and specifically for 12th class
@theinsanehuman2005
@theinsanehuman2005 3 жыл бұрын
16:25 time Complexity -----O(n) & space C------------O(n) 17:36 time complexity --------O(n) & space C--------------- O(n) 21:45 time compl ----O(n) & space C------ O(n) 30:02 Time Complexity O(2^n) & Space C ------- O(n) 39:44 time complexity--------- O(length of number) & space Complexity-------- O( length of number) 46:53 time complexity ----- Log(n) 54:51 Time Complexity -------O(n) & Space C -----O(n) 1:02:16 time complexicity - O(2^n) & space C - O(n) 1:11:11 time complexity O(3^n) & space C----- O(N) Thanks Bhaiya For Wonderful videos
@kushagrasaxena431
@kushagrasaxena431 3 жыл бұрын
16:27 Tail Recursion ( recursive call comes after processing ) 17:38 Head Recursion (when recursive call comes before processing) 23:35 S.C - O(n) T.C - O(n) 30:04 S.C - O(n) T.C - O(2^n) optimisation of code can be done using iterative approch (T.C will become O(n) that is linear and S.C will be O(1)) 39:47 T.C - O(no length) and S.C - O(no length ) 46:55 Fast Exponentiation T.C - Log(n) 54:51 T.C - O(n) S.C - O(n) 1:02:17 Subset question T.C will be O(2^N) and S.C will be O(N) 1:11:12 Max 3 jump question T.C will be O(3^N) and S.C will be O(N) 1:15:17 Subsequence Question T.C will be O( 2^N ) and S.C will be O(N) 1:26:21 Permutations question T.C will be O(N*Log(N) and S.C will be O(N) 1:31:30 Destination source T.C will be O(2^(n^2) and S.C will be O(n^2) DONE SIR ❤️❤️ Thank you kushagrasaxena2019@gmail.com
@tanishqbansal8462
@tanishqbansal8462 3 жыл бұрын
1.1 TAIL RECURSIVE FUNCTION TIME COMPLEXITY-O(n) SPACE COMPLEXITY-O(n) 1.2 HEAD RECURSIVE FUNCTION TIME COMPLEXITY-O(n) SPACE COMPLEXITY-O(n) 2. TIME COMPLEXITY-O(n) SPACE COMPLEXITY-O(n) 3. TIME COMPLEXITY-O(n) SPACE COMPLEXITY-O(n) OR USING BITS MANIPULATION AND RECURSION IS SLIGHTLY OPTIMISED. YES, ALSO DO WITH USING FOR LOOP WITHOUT RECURSION. 4. TIME COMPLEXITY- O(NO. OF DIGITS IN NUMBER) SPACE COMPLEXITY - O(n) 5. TIME COMPLEXITY-O(n) SPACE COMPLEXITY-O(n) 6. TIME COMPLEXITY-O(n) SPACE COMPLEXITY-O(n) 7. TIME COMPLEXITY-O(n) SPACE COMPLEXITY-O(n) 8. TIME COMPLEXITY-O(n) SPACE COMPLEXITY-O(n) 9. TIME COMPLEXITY-O(n) SPACE COMPLEXITY-O(n) 10. TIME COMPLEXITY-O(n) SPACE COMPLEXITY-O(n)
@Voyease
@Voyease 3 жыл бұрын
Bhaiyaa aap multi talented ho yar👌 teaching v kr lete itni acchi. Awesome.
@rahatsshowcase8614
@rahatsshowcase8614 2 жыл бұрын
@babbar bhai apke c++ me to array arguement me pass karenge to pass by value hoga lekin JavaScript me aise nehi ha!Vaha par humme khud pass by reference ko pass by value me convert karna parta ha nehito powerset vali question 🤣ka ans to asman chune wala hota ha.
@rakeshsatapathy3387
@rakeshsatapathy3387 2 жыл бұрын
This is what heroes do... Proud of ur decission brother💙✌️✌️✨✨
@salmanahmedkhan3979
@salmanahmedkhan3979 3 жыл бұрын
itnay mazay se aur itnay piyare tareekay se Babbar bhaiya ne prhaya hai dil khush hogaya. Why we don't have teacher like you in our colleges and universities. Btw, lots of love from Pakistan
@tech_wizard9315
@tech_wizard9315 3 жыл бұрын
How was the video? Did this video helped you as a beginner to solve medium/hard level problem easily??
@salmanahmedkhan3979
@salmanahmedkhan3979 3 жыл бұрын
@@tech_wizard9315 As a beginner it will take time to solve, however I am in my fifth semester of 4 year bachelor degree so I have a good grip. The video is perfect to learn recursion as a beginner. It is the well explained video I got on KZbin.
@tech_wizard9315
@tech_wizard9315 3 жыл бұрын
@@salmanahmedkhan3979 After seeing this video, Will I be able to solve Hard and medium level problems easily?
@salmanahmedkhan3979
@salmanahmedkhan3979 3 жыл бұрын
@@tech_wizard9315 First you should be able to solve easy problem. Once you have a good understanding of how recursion works then you may solve medium problems. Also, don't just jump from solving one easy towards medium problems. First solve 15-20 easy problem then if you feel you understand recursion good then go for medium and after solving 10-15 medium problems then go for hard problems. That's what I recommend. Moreover, this video will help you in understanding basics of recursion. Hope it helps
@tech_wizard9315
@tech_wizard9315 3 жыл бұрын
@@salmanahmedkhan3979 where you able to solve Hard and medium level problems after watching this video?
@hakuna_matata2108
@hakuna_matata2108 3 жыл бұрын
love sir , apki one shot videos are the best , looking forward to more of these
@priyajoshi5429
@priyajoshi5429 3 жыл бұрын
1. Counting : Tail(5,4,3,2,1) Head(1,2,3,4,5) Time complexity-O(n) Space complexity - O(n) 2. Factorial: T(c)-O(n) S(c)- O(n) 3. Fibonnaci: T(c) - O(2^n) S(c) - O(n) Can be optimised using iterative method 4. Spelling: T(c) - O(Len of number) S(c) - O(Len of number) 5. Sorted or unsorted T(c) - O(n) S(c) - O(n) 6. Exponent T(c) - O(log n) S(c) - O(n) 7. Subset T(c) - O(2^n) S(c) - O(n) 8. Jumps T(c) - O(3^n) S(c) - O(n) 9. Subsequence T(c) - O(2^n) S(c) - O(n) 10. Permutation T(c) - O(n*n!) S(c) - O(n)
@Kunalsingh-ef2lj
@Kunalsingh-ef2lj 3 жыл бұрын
16:20 Tail recursion hai kyuki recursive statement is the last statement in the function Time complexity - O(n) , space complexity - O(n) 17:38 Head recursion hai kyuki recursive statement is not the last statement in the function Time complexity - O(n) , space complexity - O(1) 23:25 Time complexity - O(n) , space complexity - O(n) 30:00 Before optimization Time complexity - O(2^n) , space complexity - O(n) It can be optimized by using an extra space, we can use an array we can store all the values so that we have to calculate the values only once and we can call it whenever required. I think isshi ko dynamic programming kehte hai par woh mujhe abhi aata nahi hai 😂😂 ok toh jab seekh loonga toh code kar lunga par space use karege toh Time complexity - O(n) and space complexity - O(n) hoga shayad. 39:43 Time complexity - O(logn) , space complexity - O(logn) 46:00 Time complexity - O(logn) 54:30 Time complexity - O(n) Space complexity - O(n) 1:02:30 Power set ----- Time complexity - O(2^n) , space complexity - O(n) 1:11:05 Time complexity - O(3^n) , space complexity - O(n) 1:15:15 Subsequence of string ---- Time complexity - O(2^n) , space complexity - O(n) Bhaiya bits se ho jayega ye question. public List AllPossibleStrings(String s) { int l=s.length(); int k=0; String str[]=new String[(1
@RamChoudhary
@RamChoudhary 3 жыл бұрын
17:36 head recursion qki phle head tk gya fir vapis aate time working ki
@harshii3110
@harshii3110 3 жыл бұрын
--- 16:23 Tail Recursion T.C O(n) & S.C O(n) ---17:37 Head Recursion T.C O(n) & S.C O(n) ---23:22 T.C O(n) & S.C O(n) ---30:05 T.C O(2^n) & S.C O(n) Optimization Using DP: TC:O(n) S.C:O(n) #include using namespace std; int fib(int n){ int dp[n+2]; dp[0]=0; dp[1]=1; for(int i=2;i>n; coutn; int n1 =0; int n2 =1; int ans=0; for ( int i = 2; i
@devangmathur5809
@devangmathur5809 2 жыл бұрын
Got Voucher?
@mirellemartis1017
@mirellemartis1017 3 жыл бұрын
exponent wala aur aasan hosakta tha na? #include using namespace std; int power(int n,int p) { if(p==0) { return 1; } int ans = n*power(n,p-1); return ans; } int main() { int n,p; cin>>n>>p; cout
@vaibhavsinhbihola1
@vaibhavsinhbihola1 3 жыл бұрын
16:20 Tail recursion bcz function call after printing 17:30 Head recursion bcz function call before printing Time complexity:- O(n) For factorial() Time complexity:-O(n) For Fibonacci () Time complexity:-O(n) For spell() Time complexity:-O(n)
@shrutikc2757
@shrutikc2757 3 жыл бұрын
1- 16:20 Tail recursion ( TC - O(n), SC-O(n)) 2- 17:34 Head recursion ( TC - O(n), SC-O(n)) 3- 23:18 Factorial( TC - O(n), SC-O(n)) 4- 29:55 Fibonacci TC - O(2^n), SC-O(n) Yes, we can optimize using iteration(TC - O(n), SC-O(1)) 5- 39:46 Spelling ( TC - O(length of no), SC-O(length of no)) 6- 39:56 Fast Exponential (TC -O(logN), SC - O(1)) 7- 47:51 Sorted or unsorted (TC- O(n), SC- O(n)) 8 - 56:33 SUBSET Recursion: TC-O(2^n), SC-O(n) Bitmasking Approach(TC - O(n*2^n) , SC - O(n) 9 - 1:02:48 Staircase (TC- O(3^n), SC- O(n)) 10 - 1: 11:44 Subsequence (TC - O(2^n), SC- O(n)) 11 - 1:16:35 Permutation (TC - O(n*n!), SC- O(n)) 12 - 1:26:41 Src to Destination(TC - O(n*n), SC- O(n*n)) Thanku bhaiya for this wonderful video on recursion. Email id: ishrutikc@gmail.com
@saumya1519
@saumya1519 3 жыл бұрын
Bhaiya was waiting for this one since the time you said you'll be making it simple 🥺
@anshumanpanigrahi7817
@anshumanpanigrahi7817 3 жыл бұрын
Why were you waiting when there is tons of resources available online
@priyanknamdeo7425
@priyanknamdeo7425 3 жыл бұрын
1. Head Recursion 2. Tail Recursion 3. Space Complexity O(n) , Time Complexity O(n) 4. It can be solved using DP approach Time complex of code using recursion O(2^n) Space Complexity O(n).
@sahithichalla2166
@sahithichalla2166 3 жыл бұрын
1)Head Recursion 2)Tail Recursion 3)sc:o(n),tc:o(n) 4)we can solve using dynamic programming Tc of the code using recursion:o(2^n) Sc:o(n)
@arindamdutta7369
@arindamdutta7369 3 жыл бұрын
16:17 Tail recursion 16:42 Head recursion 23:22 O(n) for tie and space complexity
@VijayPatel-ez4lp
@VijayPatel-ez4lp 2 жыл бұрын
your teaching style awesome thanku bhaiya🙏🙏
@kanupriya9597
@kanupriya9597 3 жыл бұрын
16:25 Tail recursion 17:35 head recursion 23:33 T.C=O(n), S.C=O(n) 30:02 T.C=O(2^n), S.C=O(n), yes, we can optimise this code we can use memoisation and recursion but to optimise it further we can use bottom up dp in iterative manner 39:46 T.C=O(length of number), S.C=O(length of number) 46:37 T.C of fast exponentiation = O(log n) 1:02:11 subset or power set T.C=O(2^n), S.C=O(n) 1:11:10 staircase question T.C=O(3^n), S.C=O(n) 1:15:31 Subsequence T.C=O(2^n), S.C=O(n). yes, we can optimise this approach using dp 1:24:54 Premutation TC: O(n*n!), SC: O(n) email: kanupriya1125@gmail.com
Complete Recursion in 1 Video || Beginners Guide 2021
5:20
Love Babbar
Рет қаралды 49 М.
16.1 Recursion - Introduction | C++ Placement Course
23:51
Apna College
Рет қаралды 405 М.
А что бы ты сделал? @LimbLossBoss
00:17
История одного вокалиста
Рет қаралды 9 МЛН
ДЕНЬ УЧИТЕЛЯ В ШКОЛЕ
01:00
SIDELNIKOVVV
Рет қаралды 4,2 МЛН
Когда отец одевает ребёнка @JaySharon
00:16
История одного вокалиста
Рет қаралды 14 МЛН
Officer Rabbit is so bad. He made Luffy deaf. #funny #supersiblings #comedy
00:18
Funny superhero siblings
Рет қаралды 19 МЛН
5 Simple Steps for Solving Any Recursive Problem
21:03
Reducible
Рет қаралды 1,2 МЛН
Lecture 31: Learning Recursion the Best Way! | 10 Day Recursion Challenge
37:36
CodeHelp - by Babbar
Рет қаралды 612 М.
Fastest way to learn Data Structures and Algorithms
8:42
Sahil & Sarra
Рет қаралды 219 М.
CS224V Fall 2024 Lecture 1: Introduction on 9 23 2024 Mon
1:29:00
StanfordCSVideos
Рет қаралды 865
Learn useContext Hook in depth
30:18
CodeHelp - by Babbar
Рет қаралды 9 М.
Viral Video of a Man's Crazy Job Interview
16:02
Darryl Vega TV
Рет қаралды 1,4 МЛН
Is Computer Science still worth it?
20:08
NeetCodeIO
Рет қаралды 407 М.
MIT Introduction to Deep Learning | 6.S191
1:09:58
Alexander Amini
Рет қаралды 647 М.
you will never ask about pointers again after watching this video
8:03
А что бы ты сделал? @LimbLossBoss
00:17
История одного вокалиста
Рет қаралды 9 МЛН