Re: ordinate a sequences of number
- From: "e p chandler" <epc8@xxxxxxxx>
- Date: 30 Oct 2005 03:26:17 -0800
gambato@xxxxxxxxxxxx wrote:
> ....I want to organize all my numbers so that the first is the
> smallest one and the last is the bigger one.
> why do you say that I haven't yet read the elements from 2 to n?
> I thought: I read n-1 elements and I compare the first elements with
> successive one (j=2,n) and so on the second one with j=3,n, etc....
> But the problem is that the program doesn't save the ordinate numbers
> in the array pos(i).
Read all of the numbers first. Then sort them.
For a data set with over 100000 items, the performance of any sorting
routine that compares each item with every other item is going to be
dismal. Look up "comb sort". It is easy to code. It is about half as
fast as quick sort. Usually this is good enough.
Last, what do you want POS() to contain? The sorted data OR the index
of the sorted data in the un-sorted list?
For example, given data
9 3 4
should POS() contain the sorted data
3 4 9
or should it be
2 3 1
If the latter, then you need to fill POS() with the integers 1 to N
before you sort. Then you must modify your sort routine so that it
references X(POS(I)) instead of X(I).
e-mail: epc8 at juno dot com
.
- Follow-Ups:
- Re: ordinate a sequences of number
- From: gambato
- Re: ordinate a sequences of number
- References:
- ordinate a sequences of number
- From: gambato
- Re: ordinate a sequences of number
- From: Ron Shepard
- Re: ordinate a sequences of number
- From: gambato
- ordinate a sequences of number
- Prev by Date: Re: ordinate a sequences of number
- Next by Date: Re: ordinate a sequences of number
- Previous by thread: Re: ordinate a sequences of number
- Next by thread: Re: ordinate a sequences of number
- Index(es):
Relevant Pages
|