AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Sort numbers from two lists

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java Help
View previous topic :: View next topic  
Author Message
Guest






PostPosted: Fri Jun 23, 2006 5:57 pm    Post subject: Sort numbers from two lists Reply with 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
Back to top
Googmeister
Guest





PostPosted: Fri Jun 23, 2006 7:18 pm    Post subject: Re: Sort numbers from two lists Reply with quote



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





PostPosted: Sat Jun 24, 2006 3:15 am    Post subject: Re: Sort numbers from two lists Reply with quote



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
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java Help All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.