![]() |
Linked Lists: Insertion Sort, RECURSIVELY
how does one do a recursive insertion sort on a linked list, particularly with these given parameters:
InsertSortR(std::string ItemName, ListItemNode* &node); Also, how does one do a recursive traverse of a linked list, AND something else at the same time, such as add up values in that linked list? |
Re: Linked Lists: Insertion Sort, RECURSIVELY
I'll answer your second question. Maybe that will help you think up the answer to your first question.
:
function sumlist(linkedListNode node), returns an integer: |
Re: Linked Lists: Insertion Sort, RECURSIVELY
thanks but they do seem to be separate things... I don't think I ever clearly explained myself on the whole traverse thing... it's confusing because I can't figure out where the variable to be added onto is in this massive scheme of classes, i/o, and pointers. But InsertSortR should be more clear, I just need to know how to implement it!
|
Re: Linked Lists: Insertion Sort, RECURSIVELY
Because you are traversing the list recursively it is acting somewhat like a stack.
Once you take a look at a node you return its value + the value of the next, this keeps on going until you hit the last node when you return the value of all the nodes added up. Hopefully this clears it up. |
Re: Linked Lists: Insertion Sort, RECURSIVELY
Quote:
|
| All times are GMT -5. The time now is 4:19 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC