Pls Help: Insertion sort using pointer notation

This is a discussion on Pls Help: Insertion sort using pointer notation within the C Programming forums, part of the General Programming Boards category; Hi, How do I convert this code from an ascending insertion sort to a descending sort..Also, if some one could ...

  1. #1
    Registered User
    Join Date
    Feb 2002
    Posts
    5

    Question Pls Help: Insertion sort using pointer notation

    Hi,
    How do I convert this code from an ascending insertion sort to a descending sort..Also, if some one could please explain the last 6-7lines of the code it would be very helpful! Thank you!

    void inserSort(int *orgAry, int *sortAry, int *plast)
    {
    /* Local Declaration */
    int *pOrg;
    int *pWalk;
    int located;
    int temp;

    /* Statements */
    for (pOrg = orgAry + 1; pOrg <= plast; pOrg++)
    {
    located = FALSE;
    temp = *pOrg;
    for(pWalk = pOrg - 1; pWalk >= orgAry && !located
    if(temp < *pWalk)
    {
    *(pWalk +1) = *pWalk;
    pWalk--;
    }/* if */
    else
    located = TRUE;

    *(pWalk + 1) = temp;
    }/* for pOrg */
    sortAry = pOrg - 1;
    return;
    }/* inserSort */

  2. #2
    Registered User
    Join Date
    Feb 2002
    Posts
    5
    Thanks man!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 26
    Last Post: 07-05-2010, 10:43 AM
  2. Replies: 5
    Last Post: 08-02-2008, 06:23 AM
  3. Insertion Sort on Array of Structs
    By n0r3gr3tz in forum C Programming
    Replies: 3
    Last Post: 04-01-2008, 08:28 AM
  4. recursive insertion sort.
    By Alien_Freak in forum C++ Programming
    Replies: 3
    Last Post: 03-23-2002, 12:31 AM
  5. Replies: 4
    Last Post: 11-05-2001, 01:35 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21