Перейти к содержимому

Recursion Explained: The Function That Calls Itself

Bitwise Tales

0:00 / 0:00

Recursion Explained: The Function That Calls Itself

70 просмотров · 6 дн. назад
Bitwise Tales
36 подписчиков
70 просмотров · 6 дн. назад
How big is a folder, when folders can hold folders, forever? Recursion answers it in a few lines. This animated explanation covers the idea behind recursion (solving a problem through a smaller version of itself), base case and recursive case, what really happens on the call stack, why a missing base case ends in a StackOverflowError, the recursive leap of faith, the classic "maximum depth of a binary tree" interview question, why naive recursive Fibonacci needs over forty billion calls, and how memoization brings that down to about a hundred. Plus: when to use a loop instead. Previous episode, binary search trees:    • Binary Search Trees Explained: Sorted AND ...   Chapters: 0:00 Intro: how big is a folder? 0:41 The idea: a queue that counts itself 1:39 Base case and recursive case 2:06 Factorial in Java 2:36 The call stack: push and unwind 3:26 Stack overflow: no base case 4:00 Measuring folders recursively 4:58 Trees and the recursive leap of faith 5:33 Interview: maximum depth of a binary tree 6:13 Fibonacci and memoization 7:17 Recursion or loops? 7:58 Recap in one breath Bitwise Tales: tech explained like a story, not a textbook.