@Koda Jax its only getting the information and not the real password.. and the password covered with stars is not the same with the real password.. i know it because i tried to hack myself but the length of the stars is different with my password
And what about the cost of the algorithm? As far as I know, some algorithms require fewer calculations in a recursive way. Maybe you can do it as cheap as recursive ones in iterative but I think the code will be really hard to understand.
I am very thankful to neso academy which helped me in clearing subjects like automata theory and digital logic.....sir can u inform when r u going to start lectures on python programming...
Recursive functions are more "elegant" (what that word even means in programming... rather sounds like an ego thing) and easy to understand? I strongly disagree. Any level of programmer would understand most loops/iterations at a glance, but a recursive function which is not only these dummy examples with 4 lines of code, I think most would be lost at first (include me).
Not in the example he gave, recursion provides a performance benefit when your problem can apply a divide and conquer approach to solving it. The factorial calculation just provides a good way to visualize the way recursion works. Any problem that needs to search a tree structure tends to be a good example of where you can use recursion efficiently.
yes it can.the first link explains it.the 2nd and third ara 2 codes of Ackermann function without recursion(iteratively) www.quora.com/Why-cant-Ackermann-function-be-calculated-iteratively gist.github.com/Sebbyastian/9bf5551f915b2694c77e codereview.stackexchange.com/questions/156552/iterative-implementation-of-the-ackermann-function
The Ackermann function can be computed iteratively. However, the Ackermann function is not a primitive recursive function, and this fact is connected to one specific type of iterative computation. Intuitively, primitive recursive functions are functions that can be implemented in a simple programming language in which the only type of iteration you can use is a for-cycle with a fixed number of iterations. (I.e., when the for-cycle starts, you have to state the lower and upper bound of the iteration, and you cannot cheat by modifying the iteration variable inside the cycle.) The result that the Ackermann function is computable but not primitive recursive is important because it shows that the for-cycle, on its own, is not strong enough to make a programming language Turing complete. You need a stronger form of iteration, for example a while-cycle, or general recursion.
Stack helps the program know where in the code it is. When you call a function your program must know where it was before calling it, so it can return there after completing the function. Also the stack keeps registers saved in case you alter any of them during function execution, so that they can be returned to "normal" after completed
I find it really bewildering hearing programmers using terms like: "elegant" "clean" "simple" - because these are not quantifiable, but rather a matter of personal taste or even a tradition ("all the developers say that..." "all the developers learned from other developers to like/praise/appreciate it that way ...". E.g. I find iteration more systematic (or even linear) approach and therefore easier to comprehend (what is being done when) then recursion, that forces ones mind to wrap itself around non-linear thinking (something calling itself calling itself ...). Despite developers pointing fingers at recursion and saying it looks cleaner/simpler - when it actually does not. :) I yet have to find explanations that sound technical. I'd be more interested in number of operations, memory use, speed etc.
So, what I got from that was... always do iterative. Who cares about 'elegance'? If iterative uses less memory and executes faster, then it's just better. But I'm a total newbie, so maybe I'm totally misconstruing something here?
It is actually not that way. Elegance and less lines of code enhance readability and understanding of programs, which can be ignored in simpler programs but is of paramount importance in long and complex programs.
Actually, I think the number of lines of code is also defines the space. Here, recursion has less number of lines but it occupies more stack space than iteration, then please let me know that what is the actual relationship between number of lines and the memory?
advantage of recursion you just have freaking less line like 1 or 2 lines and it's look more complex that make you think yourself looks cool at the cost of using stack and sometimes transverse tree. best loop vs best recursion of a program always perform better the loops that is and guess what sometimes recursion only get better when the compiler change it's to loop using what's called "tail call optimization" the only to write it if you're in a hurry and you also used to recursion else it's suck for other programmer
100% no-nonsense content...
keep up the great work sir... we count on u.
I like the way you say "let me tell you my dear friend" lol...
@Koda Jax wtf
@Koda Jax its only getting the information and not the real password.. and the password covered with stars is not the same with the real password.. i know it because i tried to hack myself but the length of the stars is different with my password
@Avery Johnny buzzeerrr
Great job sir. You are making things simpler for us and love you
Recursive Program
Advantage: Elegant
Disadvantage: Complex
Iterative Program
Advantage: Simple
Disadvantage: Lengthy
Lengthy and ugly, you guys better become average recursion enjoyers, not average loops fans
instablaster...
@@sweatyhands9830
Lengthy and ugly in what kind of case?
@@lucascabrellibr in every case. i don't like loops
@@sweatyhands9830 but it's hard
Easily Understood. Explanation Superb Sir.
Super explanation sir your videos are amazing
Your lectures r fantastic... Very much helpful
Awesome explanation.
And what about the cost of the algorithm?
As far as I know, some algorithms require fewer calculations in a recursive way. Maybe you can do it as cheap as recursive ones in iterative but I think the code will be really hard to understand.
You are the best teacher, I mean it!
Sir, can u tell me the practical example where loop is better than recursion and viceversa
I am very thankful to neso academy which helped me in clearing subjects like automata theory and digital logic.....sir can u inform when r u going to start lectures on python programming...
Python is started now.
Grate sir keep it up
Recursive functions are more "elegant" (what that word even means in programming... rather sounds like an ego thing) and easy to understand?
I strongly disagree. Any level of programmer would understand most loops/iterations at a glance, but a recursive function which is not only these dummy examples with 4 lines of code, I think most would be lost at first (include me).
Nice explanation
You can't implement Ackermann's recursive function with iteration..
@Neso Academy, is it also the case that the recursive approach is faster in time in comparison to iterative for real world coding implementation?
Not in the example he gave, recursion provides a performance benefit when your problem can apply a divide and conquer approach to solving it. The factorial calculation just provides a good way to visualize the way recursion works. Any problem that needs to search a tree structure tends to be a good example of where you can use recursion efficiently.
Thanks for helping us sir
Correction at 1:14,
Every recursive code cannot be written iteratively like the Ackermann function
yes it can.the first link explains it.the 2nd and third ara 2 codes of Ackermann function without recursion(iteratively)
www.quora.com/Why-cant-Ackermann-function-be-calculated-iteratively
gist.github.com/Sebbyastian/9bf5551f915b2694c77e
codereview.stackexchange.com/questions/156552/iterative-implementation-of-the-ackermann-function
Thanks @red_l
The Ackermann function can be computed iteratively. However, the Ackermann function is not a primitive recursive function, and this fact is connected to one specific type of iterative computation.
Intuitively, primitive recursive functions are functions that can be implemented in a simple programming language in which the only type of iteration you can use is a for-cycle with a fixed number of iterations. (I.e., when the for-cycle starts, you have to state the lower and upper bound of the iteration, and you cannot cheat by modifying the iteration variable inside the cycle.)
The result that the Ackermann function is computable but not primitive recursive is important because it shows that the for-cycle, on its own, is not strong enough to make a programming language Turing complete. You need a stronger form of iteration, for example a while-cycle, or general recursion.
Sir, every iterative problems can we write with the help of recursion?
nope
Sir can you please let us know the solution of home work problems btw best video lectures on youtube
what is the actual relationship between number of lines and the memory?
Situationship
Great video! Do more stack frames mean more computational time? I feel like that would be true but I’m not sure
No stack frame is free memory during runtime.
Does recursion take more stack memory than iteration?
احلي تحيه لرجاله الهند
where are the data structures part in this series?
Thank you so much
Please provide computational time difference if any
Which path should we follow in competitive and interview based programming!??
Can anyone recall me what is stack and what is the use of it?
Stack helps the program know where in the code it is. When you call a function your program must know where it was before calling it, so it can return there after completing the function. Also the stack keeps registers saved in case you alter any of them during function execution, so that they can be returned to "normal" after completed
Program-1: tail recursive
Program-2: non tail recursive
int fact(int n):
if n < 0: return -1
result = 1:
for(int x = 1; x < n; x++):
result *= x
return result
vio la! same lines of code
Condition would be x
@@mihirvora391 buggy isnt it haha
I find it really bewildering hearing programmers using terms like: "elegant" "clean" "simple" - because these are not quantifiable, but rather a matter of personal taste or even a tradition ("all the developers say that..." "all the developers learned from other developers to like/praise/appreciate it that way ...".
E.g. I find iteration more systematic (or even linear) approach and therefore easier to comprehend (what is being done when) then recursion, that forces ones mind to wrap itself around non-linear thinking (something calling itself calling itself ...). Despite developers pointing fingers at recursion and saying it looks cleaner/simpler - when it actually does not. :)
I yet have to find explanations that sound technical. I'd be more interested in number of operations, memory use, speed etc.
Which path is fast?
Idk
Iterative bro
Difference between Recursion vs callback function pls tell
So, what I got from that was... always do iterative. Who cares about 'elegance'? If iterative uses less memory and executes faster, then it's just better. But I'm a total newbie, so maybe I'm totally misconstruing something here?
It is actually not that way. Elegance and less lines of code enhance readability and understanding of programs, which can be ignored in simpler programs but is of paramount importance in long and complex programs.
What about the performance?
sir, what about the time complexity which one is better?
Iterations
Actually, I think the number of lines of code is also defines the space. Here, recursion has less number of lines but it occupies more stack space than iteration, then please let me know that what is the actual relationship between number of lines and the memory?
Thank u
advantage of recursion you just have freaking less line like 1 or 2 lines and it's look more complex that make you think yourself looks cool
at the cost of using stack and sometimes transverse tree.
best loop vs best recursion of a program always perform better the loops that is
and guess what sometimes recursion only get better when the compiler change it's to loop using what's called "tail call optimization"
the only to write it if you're in a hurry and you also used to recursion else it's suck for other programmer
Nice
Which path takes less time!
Iteration is always faster than recursion except in the case that the method call goes straight the recursive methods base case
Except we know that recursion is not more elegant and actually requires more memory than iterative.
Sorry to say Advantage and Disadvantage of Recursion was not mentioned properly here.
🖤🖤
but for me, iterative is easier to understand
Sir please hindi me bole 😢😢😢
but doesnt more lines mean more space
More space in RAM. Also can be bigger compiled.
Space will be occupied when you store something
In recursion we store value at every function call