filmov
tv
Find the Length of an Array or List Using Recursion
![preview_player](https://i.ytimg.com/vi/mxuvcQdL--o/maxresdefault.jpg)
Показать описание
In this video, I will show you how to find the length of an array or list using recursion. For example, if we have an array [a, b, c], then the recursive function will return 3, because that is the size or length of the array.
Now you might be wondering, why don't we just use the built-in length function which is provided by most programming languages? Well, if a test says that you cannot use the built-in length function, then you must know how to do this recursively (true story).
So what exactly is recursion? Recursion is a function that calls upon itself. Here, we write a function that calls upon itself and to determine the size and length of a list using recursion. While it is easy to use a for loop or while loop to do this, it is important that you understand these recursion steps to have a strong foundation to learn more complex recursive algorithm in the future.
In the next video, I will show you how to convert an array to a string using recursion.
LIKE & SUBSCRIBE:
MY EQUIPMENT:
✅Camera: Samsung Galaxy J7
✅Editing Software: Shotcut
Now you might be wondering, why don't we just use the built-in length function which is provided by most programming languages? Well, if a test says that you cannot use the built-in length function, then you must know how to do this recursively (true story).
So what exactly is recursion? Recursion is a function that calls upon itself. Here, we write a function that calls upon itself and to determine the size and length of a list using recursion. While it is easy to use a for loop or while loop to do this, it is important that you understand these recursion steps to have a strong foundation to learn more complex recursive algorithm in the future.
In the next video, I will show you how to convert an array to a string using recursion.
LIKE & SUBSCRIBE:
MY EQUIPMENT:
✅Camera: Samsung Galaxy J7
✅Editing Software: Shotcut