home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!stanford.edu!CSD-NewsHost.Stanford.EDU!Xenon.Stanford.EDU!amorgan
- From: amorgan@Xenon.Stanford.EDU (Crunchy Frog)
- Subject: Re: array element swap help
- Message-ID: <1992Jul30.220758.14925@CSD-NewsHost.Stanford.EDU>
- Sender: news@CSD-NewsHost.Stanford.EDU
- Organization: Computer Science Department, Stanford University.
- References: <1992Jul30.161648.26055@news.iastate.edu> <1992Jul30.185540.10776@CSD-NewsHost.Stanford.EDU> <1992Jul30.203049.2800@klaava.Helsinki.FI>
- Date: Thu, 30 Jul 1992 22:07:58 GMT
- Lines: 29
-
- In article <1992Jul30.203049.2800@klaava.Helsinki.FI>
- wirzeniu@klaava.Helsinki.FI (Lars Wirzenius) writes:
- >amorgan@Xenon.Stanford.EDU (Crunchy Frog) writes:
- >>Oh, there is no real way to speed [swapping] up [...]
- >
- >The best way to speed it up is to eliminate it altogether.
-
- Huh? Maybe the constant drug use is getting to me, but I don't see how
- you can do that. Sure, you can reduce it by using a better sort
- (as you say below), but to sort things you have to change their position.
-
- >The problem
- >arose for a sorting application, so perhaps there is a better sorting
- >algorithm that could be used (use Quicksort instead of Bubble sort).
-
- Agreed. I said the request seemed a little weird.
-
- >On the other hand, if the array elements are large (some kinds of
- >structures, say), you can probably speed things up by using an array of
- >pointers to said structures instead. The purpose is to make the array
- >elements smaller and thereby reducing the amount of data that has to be
- >moved.
-
- Yep. I alluded to this in my posting, but since I wasn't sure what
- the original poster was up to I didn't bother specifying it.
-
- >Lars.Wirzenius@helsinki.fi
-
- C Frog
-