Relative Content

Tag Archive for pythonalgorithmrecursion

Recursion in programing

I’ve been using python to code simple algorithms from Introduction to Algorithms and recursion algorithms started,I’m aware what is this and how to use it more or less since I’ve had it long ago in high school when we’ve been using c++ to do it.The problem is that while the code for recursion isn’t often that hard when you see it written already,it even looks really simple and easy to get at the first glance but when I start wondering how computer really treats it,it really makes my head spin a bit.I’ve seen all those visualisations of algoritms like MergeSort or Binary Search.My problem is that I don’t understand how function can call itself so many times with different data input and output till it reaches the bottom and then works it’s way up again connecting the data it has already used into an answer one by one.I don’t understand how compiler can remember all those ‘past’ data it has already used and go down from recursion tree to bottom and then again up.

How does recurrence works in programing?

I’ve been using python to code simple algorithms from Introduction to Algorithms and recursion algorithms started,I’m aware what is this and how to use it more or less since I’ve had it long ago in high school when we’ve been using c++ to do it.The problem is that while the code for recursion isn’t often that hard when you see it written already,it even looks really simple and easy to get at the first glance but when I start wondering how computer really treats it,it really makes my head spin a bit.I’ve seen all those visualisations of algoritms like MergeSort or Binary Search.My problem is that I don’t understand how function can call itself so many times with different data input and output till it reaches the bottom and then works it’s way up again connecting the data it has already used into an answer one by one.I don’t understand how compiler can remember all those ‘past’ data it has already used and go down from recursion tree to bottom and then again up.