We've been given the following line...
public Node less (int n, Node l)
We have to use recursion to write a method which takes as input a linked list and a number and return a list of elements smaller than that number.
Originally posted by Charlie Jackpot:
Fixed.
Originally posted by Charlie Jackpot:
I think "Node l" refers to the linked list.
Originally posted by Henry Wong:
Okay good. And n is referring to the number to be compared to. With this you can form the method.
Now, did your instructor teach you the algorithm for the quick sort? Can you form the body of the method, from what you were taught?
Henry
Originally posted by Charlie Jackson:
Well, he gave us the quicksort method but used it on an Array.
I am not sure how to use it with Linked Lists.
Originally posted by Henry Wong:
Well, it is the technique that is important. If you understood how it worked with an array, it is easily translated to a linked list. Just take a shot at it, provide the code here, and we can give you hints in the right direction.
Now... Did your instructor provide you with the implementation for Node? Or are you expected to implement your own linked list too?
Henry
I don't understand it for Array either
Originally posted by Campbell Ritchie:
There appear to be problems about sorting LinkedLists; the Collections class copies the list into an array.
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them. - Laurence J. Peter
Well doneOriginally posted by Charlie Jackson:
I've finished my "sort" class.