Re: Quicker then QuickSort???
From: Kristofer Gafvert (kgafvert_at_NEWSilopia.com)
Date: 05/10/04
- Next message: Ben Dewey: "Re: DateTime formating"
- Previous message: TT \(Tom Tempelaere\): "Re: How do I gently terminate a thread???"
- In reply to: madler: "Quicker then QuickSort???"
- Next in thread: Tim Clark: "Re: Quicker then QuickSort???"
- Reply: Tim Clark: "Re: Quicker then QuickSort???"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 10 May 2004 20:11:34 +0200
Hello,
Have you tried your algorithm with all kind of different data input? Without
pseudo code, i cannot tell you the O(n) for this algorithm (because i am
lazy today), but that is not the main point of my message. The point with my
message is that all algorithms have advantages, and disadvantages, and you
should consider how the data used to sort look like, if you have any upper
bound limit, and then select the best algorithm for that. With "correct"
formed input data, you can get the fastest algorithm to run slower than the
one that should run slowest.
Bruno R. Preiss has a really good website about algorithms and data
structures here:
http://www.brpreiss.com/books/opus6/
(click web book)
He has a complete chapter about Sorting Algorithms that you might find
useful.
-- Regards, Kristofer Gafvert - IIS MVP http://www.ilopia.com - When you need help! "madler" <anonymous@discussions.microsoft.com> wrote in message news:A205F4F4-C7E5-4927-8B36-FB3A235B29AB@microsoft.com... > Hi. > > I might be a bit niave here but I was looking over a quicksort implementation (provide by compuware as a sample for DevPartner Profiler community edition) and I thought that I could do better then that. So I implemented my own simple sorting algoritim and it seems to run twice as fast as the quicksort. > > So my question is - What is the catch with my algorithim - why do all libraries include the very complex QuickSort when something as simple as what I did is not used. I am sure that people have explored the same method before. Does anyone know what it's shortcomes are? > > Here is the method: > > int lval,lpos; > int hval,hpos; > lpos = 0; > hpos = 0; > lval = 1000000; > hval = 0; > for (int i = 0 ;i<(numElems /2);i++) > { > > flag = false; > int j; > lval = hval; > hval = 0; > for (j = i;j<((numElems -i)-1);j++) > { > int c = Elements[j]; > if (c < lval) > { > lpos = j; > lval = c; > > } > if (c > hval) > { > hpos = j; > hval = c; > > } > } > > SwapEm(i,lpos); > SwapEm(j,hpos); > > } > > > Thanks
- Next message: Ben Dewey: "Re: DateTime formating"
- Previous message: TT \(Tom Tempelaere\): "Re: How do I gently terminate a thread???"
- In reply to: madler: "Quicker then QuickSort???"
- Next in thread: Tim Clark: "Re: Quicker then QuickSort???"
- Reply: Tim Clark: "Re: Quicker then QuickSort???"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|