Re: Help needed for a sorting code in the literature

From: BRG (brg_at_nowhere.org)
Date: 12/31/04


Date: Fri, 31 Dec 2004 13:48:36 +0000

BRG wrote:
> Mok-Kong Shen wrote:
>
>> The code of the heapsort algorithm as given in books by
>> e.g. Sedgewick deals with arrays with indices of the kind
>> a[1..n]. For PLs like C, one would like to sort arrays with
>> indices of the kind a[0..n-1]. I have found sofar only one
>> book that gives code for the latter case, namely "Numerical
>> Recipes in C++" by W. H. Press et al. (which itself refers
>> to Sedgewick). I adapted the code there (which is in C++
>> and is capable of dealing with a variety of data types being
>> sorted) to C for sorting arrays of 'int'.
>
>
> Here is a C++ version of a bottom up heapsort that should be easy to
> convert to C. No guarantees that it is correct though - posting code
> here is a virtual guaranetee that someone will find bugs in it :-)

[snip]
I have even found one myself :-(

   Brian Gladman



Relevant Pages

  • Re: Structured Coding
    ... First, thank you for reading my books, and please do not read what follows ... like the book less than I like the language. ... concepts (such as arrays and strings). ... Programming C# assumes some experience with a related language ...
    (comp.lang.cobol)
  • Re: "Thinking in C++" vs. "C++ How to Program" vs. ???
    ... >> When the Deitel and Deitel books first came out they were quite good and ... >me evaluate these books better. ... std::vector is preferred to use newfor dynamically sized arrays. ... pointers are used for association whereas smart pointers are used for ...
    (alt.comp.lang.learn.c-cpp)
  • Re: PHP MYSQL QUESTION
    ... I want to give user the option to change the range of books and chapter from which the questions are drawn from and the number of each type they want. ... I then use a 'while loop' with 'mysql_fetch_arrayto print out the results to the screen. ... 'E1','E5', 'P1') AND type='G' ORDER BY RAND() LIMIT 11)" ... because it left the last element of the array blank, and with six arrays I was ending up with 6 blank elements when I merged them, but now it works great. ...
    (alt.php)
  • Help needed for a sorting code in the literature
    ... e.g. Sedgewick deals with arrays with indices of the kind ... sorted) to C for sorting arrays of 'int'. ... I couldn't be sure whether this is due to my coding ...
    (sci.crypt)
  • Re: Collecting choices from several selection boxes and storing them
    ... > favourite books and store them in the database at a table called preferences ... PHP allows you to treat form fields as arrays if you give them the ... I particularly love arrays. ...
    (comp.lang.php)