Multiple Return Values: Unlocking the Power of Recursive Functions | Recursion Series
Вставка
- Опубліковано 15 лип 2024
- In this video, we dive into the fascinating world of recursive functions and learn how to return multiple values from them. Recursive functions are powerful tools that call themselves repeatedly to solve complex problems by breaking them down into smaller, more manageable subproblems. Returning multiple values from a recursive function can be particularly useful when you need to gather and analyze various pieces of information during the recursive process.
Source code repository:
github.com/williamfiset/algor...
Video slides:
github.com/williamfiset/algor...
Personal website:
williamfiset.com
Happy to see you back🎉 keep posting videos, learned lot from this channel.
Loving your amazing videos
Its been quite a long time eh ? Welcome back!!
Hello. Happy to see you back. I have always wondered about the tools you are using to produce your videos. Could you please share the tools and software you used to produce your videos?
Slides are made using keynote
what if my language 'c++' don't support null, what value should i return at base case ?
pair compare(pair pr1, pair pr2)
{
if (pr1.second > pr2.second)
return pr1;
return pr2;
}
pair maximum_func(vector vec, int index)
{
if (index == (int)vec.size() - 1)
{
pair pr;
pr.first = (int)vec.size() - 1;
pr.second = vec[(int)vec.size() - 1];
return pr;
}
pair sub;
sub.first = index;
sub.second = vec[index];
return compare(sub, maximum_func(vec, index + 1));
}
pair maximum(vector vec)
{
return maximum_func(vec, 0);
}
int main()
{
cout
You could use nullptr? Or an int wrapper object
the slides not exist in githup
i found it , but why you upload the slides with "key" extension 😂
Surely, multiple return values have to be bad practice in most cases?! Let's exclude the very odd occasion where this might be a good idea.
It's certainly seldom used. I rarely use multiple return values unless it's for recreational code. In practice if you do have to return multiple values a data object is typically the best way IMO.
😈 *Promo SM*