Click here to Skip to main content
15,891,943 members
Home / Discussions / Algorithms
   

Algorithms

 
GeneralRe: Tree algo Pin
dfreeser3-Apr-09 6:02
dfreeser3-Apr-09 6:02 
GeneralRe: Tree algo Pin
Alan Balkany3-Apr-09 6:16
Alan Balkany3-Apr-09 6:16 
GeneralRe: Tree algo Pin
dfreeser3-Apr-09 6:33
dfreeser3-Apr-09 6:33 
Questioncalculate polygon area and its centre in 3d Pin
beko31-Mar-09 22:57
beko31-Mar-09 22:57 
AnswerRe: calculate polygon area and its centre in 3d Pin
Alan Balkany1-Apr-09 3:46
Alan Balkany1-Apr-09 3:46 
GeneralRe: calculate polygon area and its centre in 3d Pin
beko1-Apr-09 19:26
beko1-Apr-09 19:26 
AnswerRe: calculate polygon area and its centre in 3d Pin
cp98761-Apr-09 20:10
cp98761-Apr-09 20:10 
QuestionStable Quicksort algorithm Pin
Member 419459331-Mar-09 6:04
Member 419459331-Mar-09 6:04 
Does anyone have a stable Quicksort? I have looked at many, and they all seem to have a problem in that they swap elements that are not equal to the pivot element before knowing whether the swapped elements match any other element. see the following example:
014447222563 where '3' is the pivot

You will swap the '4's and '2's leaving:
012227444563

and the final swap:
012223444567

however, the swaps of the '2's and '4's (done one at a time from the outside) put them out of order before you even get to see that they are duplicates.

The only way I know of is to supply an additional key element in the record (sorted along with the key) which contains the input record number of the key. This is time expensive, rebuilding the records just to sort them, only to unbuild them when the sort completes. It is easily done, however, with indirect sorting, where the indirect array is an array of structures containing both the pointer to the actual record and also the input record number. Swapping the indirect pointers as records keeps the original record number with its record definition where it can be checked when an equal comparison is encountered. Of course, indirect sorting is inefficient when huge arrays (> 2GB)are involved because the underlying data remains scattered in memory, and paging in huge blocks of memory to compare a small record is a terrible waste.

Dave Augustine
AnswerRe: Stable Quicksort algorithm Pin
Lutosław31-Mar-09 12:39
Lutosław31-Mar-09 12:39 
GeneralRe: Stable Quicksort algorithm Pin
Member 419459331-Mar-09 16:06
Member 419459331-Mar-09 16:06 
AnswerRe: Stable Quicksort algorithm Pin
Stephen Hewitt31-Mar-09 17:11
Stephen Hewitt31-Mar-09 17:11 
GeneralRe: Stable Quicksort algorithm Pin
Member 41945931-Apr-09 17:16
Member 41945931-Apr-09 17:16 
GeneralRe: Stable Quicksort algorithm Pin
supercat93-Apr-09 6:22
supercat93-Apr-09 6:22 
GeneralRe: Stable Quicksort algorithm Pin
Member 41945934-Apr-09 5:58
Member 41945934-Apr-09 5:58 
AnswerRe: Stable Quicksort algorithm [modified] Pin
bulg3-Apr-09 14:15
bulg3-Apr-09 14:15 
GeneralP.s. Pin
bulg3-Apr-09 14:28
bulg3-Apr-09 14:28 
GeneralRe: Stable Quicksort algorithm Pin
Member 41945934-Apr-09 6:36
Member 41945934-Apr-09 6:36 
GeneralRe: Stable Quicksort algorithm Pin
bulg9-Apr-09 11:42
bulg9-Apr-09 11:42 
GeneralRe: Stable Quicksort algorithm Pin
Member 41945939-Apr-09 16:51
Member 41945939-Apr-09 16:51 
QuestionVector orientation Question. Pin
Maximilien31-Mar-09 4:59
Maximilien31-Mar-09 4:59 
AnswerRe: Vector orientation Question. Pin
Luc Pattyn31-Mar-09 5:06
sitebuilderLuc Pattyn31-Mar-09 5:06 
GeneralRe: Vector orientation Question. Pin
Maximilien31-Mar-09 5:34
Maximilien31-Mar-09 5:34 
GeneralRe: whatever shape Pin
Luc Pattyn31-Mar-09 5:38
sitebuilderLuc Pattyn31-Mar-09 5:38 
GeneralRe: whatever shape Pin
Maximilien31-Mar-09 5:42
Maximilien31-Mar-09 5:42 
AnswerRe: Vector orientation Question. Pin
73Zeppelin31-Mar-09 5:13
73Zeppelin31-Mar-09 5:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.