You are viewing a single comment's thread. Return to all comments →
We can solve it using loops, but I think a recursive approach would be easier to understand.
Note: you can skip the "else return" code since it will automatically return. cmiiw.
void ReversePrint(Node *head){ if(head != NULL){ ReversePrint(head->next); cout << head->data << endl; return; } else{ return; } }
Seems like cookies are disabled on this browser, please enable them to open this website
Print in Reverse
You are viewing a single comment's thread. Return to all comments →
We can solve it using loops, but I think a recursive approach would be easier to understand.
Note: you can skip the "else return" code since it will automatically return. cmiiw.