3 ms·
One property that makes recursion attractive is that maps so easily to proof by induction. When designing algorithms, I'll often design a recursive version firs
by tmoertel 6y ago
One property that makes recursion attractive is that maps so easily to proof by induction. When designing algorithms, I'll often design a recursive version first, prove it correct, and then translate it into an iterative version. The translation is frequently required to implement the algorithm in common programming languages, most of which have poor support for recursion.
For an example, see https://github.com/tmoertel/practice/blob/master/dailycodingproblem_com/p636_find_min_of_rotated_sorted_series_of_distinct_elems.py https://github.com/tmoertel/practice/blob/master/dailycoding...