Wiki

Ticket #193 (assigned enhancement)

Opened 15 years ago

Last modified 14 years ago

Extension to HowTo/29[02]* to include shell sort

Reported by: hopscc Owned by: Chuck
Priority: minor Milestone:
Component: Cobra Compiler Version: 0.8.0
Keywords: Cc:

Description

Heres a patch to the sort examples in HowTo/?29[02]-TranslatePseudoCodeToCobra?[12].cobra
to include an example of a shellsort.

Attachments

shell-sorts.patch Download (1.7 KB) - added by hopscc 15 years ago.
shell-sorts2.patch Download (4.9 KB) - added by hopscc 15 years ago.

Change History

Changed 15 years ago by hopscc

Changed 15 years ago by Chuck

The code looks a bit different than the pseudo-code from  http://en.wikipedia.org/wiki/Shell_sort#Shell_sort_algorithm_in_pseudocode

For example, the patch has in if statement, but I don't see one in the pseudocode. The pseudocode is shorter. Am I missing something, or did the shell code for the patch come from a different source?

Why is one line of code "Decimal.toInt32(top/2) " and another "... to int"? Is there a difference in semantics? Also, you can use (x // 2) for integer division. But that's not holding the patch back, I'm curious about the other stuff.

Changed 15 years ago by hopscc

Ya, The shell code for the patch was from a different source
converted and provided for filling the suite for completeness with the other sorting algorithms. I didnt chk for a wikipedia shell sort algoritm

I cant remember what the The Decimal.... vs 'to int' diff was about, no semantic diffs that I can recall just what got working fastest...

Changed 15 years ago by hopscc

Changed 15 years ago by hopscc

modified patch using '//' and providing implementation of algorithm on wikipedia
Additional test cases for odd numbers of items

Changed 14 years ago by hopscc

  • status changed from new to assigned
Note: See TracTickets for help on using tickets.