 |
AppletTalk.com Java discussions newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Guest
|
Posted: Fri Jun 23, 2006 5:57 pm Post subject: Sort numbers from two lists |
|
|
Hello,
I have two ordered lists LIST1 and LIST2 which elements are composed of
a field named "value" (an integer number) and a field named "prox" that
points on the following element ("nil" when there aren't new elements).
The elements are disposes in each list in crescent order of value.
What's the optimal Java algorithm to print *in crescent order* the
combination of the elements of both lists?
For example, if the first list is formed by values 8, 12, 13, 28, and
the second by values 10, 11, 35, it must print the list 8, 10, 11, 12,
13, 28, 35.
Thanks in advance to all
Markus |
|
| Back to top |
|
 |
Googmeister Guest
|
Posted: Fri Jun 23, 2006 7:18 pm Post subject: Re: Sort numbers from two lists |
|
|
outmarcus (AT) gawab (DOT) com wrote:
| Quote: | Hello,
I have two ordered lists LIST1 and LIST2 which elements are composed of
a field named "value" (an integer number) and a field named "prox" that
points on the following element ("nil" when there aren't new elements).
The elements are disposes in each list in crescent order of value.
What's the optimal Java algorithm to print *in crescent order* the
combination of the elements of both lists?
For example, if the first list is formed by values 8, 12, 13, 28, and
the second by values 10, 11, 35, it must print the list 8, 10, 11, 12,
13, 28, 35.
|
Consider the merge operation from the mergesort algorithm. |
|
| Back to top |
|
 |
IchBin Guest
|
Posted: Sat Jun 24, 2006 3:15 am Post subject: Re: Sort numbers from two lists |
|
|
outmarcus (AT) gawab (DOT) com wrote:
| Quote: | Hello,
I have two ordered lists LIST1 and LIST2 which elements are composed of
a field named "value" (an integer number) and a field named "prox" that
points on the following element ("nil" when there aren't new elements).
The elements are disposes in each list in crescent order of value.
What's the optimal Java algorithm to print *in crescent order* the
combination of the elements of both lists?
For example, if the first list is formed by values 8, 12, 13, 28, and
the second by values 10, 11, 35, it must print the list 8, 10, 11, 12,
13, 28, 35.
Thanks in advance to all
Markus
When you select a Print button just do this: |
1 - extract both JList into arraylist.
2 - do the sort 'Collections.sort(arraylist)';
3 - then print out the arraylist.
Thanks in Advance...
IchBin, Pocono Lake, Pa, USA http://weconsultants.awardspace.com
__________________________________________________________________________
'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-) |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|