How would I construct a linked list using recursion.
void main()
{
Rec(5);
}
void Rec(int num)
{
if(num==5)
return;
else
<--what if I wanted to start building a linked list here with the current value of num
Rec(num+1);
}
I am not sure how to connect the current node to the next node because the next node is appended in a whole new recursive call.
rsshetty.
It's always in the details.
void main()
{
Rec(5);
}
void Rec(int num)
{
if(num==5)
return;
else
<--what if I wanted to start building a linked list here with the current value of num
Rec(num+1);
}
I am not sure how to connect the current node to the next node because the next node is appended in a whole new recursive call.
rsshetty.
It's always in the details.