I am currently having problems and need help with:
1) Printing the words in reverse order in my printList function
2) Printing the words in alphabetical order in my printList function
You need a sort function to put something in alphabetical order. printList should do that: print the list. It should have nothing to do with sorting/ordering the list. Do you have a sort function? Any sort that can be implemented on an array can be implemented on a linked list. The O values (i.e. O(n squared)) will often be different than they are for an array based sort due to lack of random access. But you still have to sort if you want to alphabetize. I see no sort function in your code.
VernonDozier
Posting Expert
5,527 posts since Jan 2008
Reputation Points: 2,633
Solved Threads: 711
nevermind, I got reverse to work finally work. I am now working on the alphabet function. Are there any advice to set it up or any principles to follow to sort words in alphabetical order?
As mentioned, you need a sort function. Bubble Sort works well with a linked list since you're only comparing neighbors. It's just like doing it with an array. Compare neighbors. Swap if they're in the wrong order. When you've gone through the whole list with no swaps, you're done.
VernonDozier
Posting Expert
5,527 posts since Jan 2008
Reputation Points: 2,633
Solved Threads: 711