Thread: bubble sort

  1. #1
    Registered User
    Join Date
    Oct 2004
    Posts
    3

    Lightbulb bubble sort

    I have the pseudocode for my bubble sort but I have a question?

    Pseudocode:

    IF full array key (start-loc) > full array key (next-loc)
    THEN move full array entry (next-loc) to save entry
    MOVE full array entry (start-loc) to full array entry (next-loc)
    MOVE save entry to full array entry (start-loc)
    ADD 1 to swap -count
    ELSE continue
    END-IF

    How I wrote my source code:

    IF (strcmp(cp[StartLoc].number, cp [NextLoc].number)>0);
    NextLoc= SaveEntry ????(Is the correct?)
    SaveEntry=StartLoc;
    swap-count++;

    Question???????
    Is my source code correct ? If not what do I need to fix?

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    What ever happened to just trying something and seeing if it worked or not?

    Go read the Announcements, and in the future, as you'll be told there, use code tags when posting code.

    You have a semi-colon at the end of your if statement, which rather defeats the point of having an if statement at all.

    I'll leave the rest up to you.

    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    ---
    Join Date
    May 2004
    Posts
    1,379
    Quote Originally Posted by quzah
    What ever happened to just trying something and seeing if it worked or not?
    Quzah.
    i was thinking the same thing

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. bubble sort not working... wats d prob?
    By Huskar in forum C Programming
    Replies: 8
    Last Post: 03-31-2009, 11:59 PM
  2. My bubble sort only sorts once
    By Muller in forum C Programming
    Replies: 8
    Last Post: 03-27-2009, 04:36 PM
  3. Bubble Sort... which type?
    By gflores in forum C++ Programming
    Replies: 8
    Last Post: 08-15-2004, 04:48 AM
  4. Bubble Sort, Qucik Sort
    By insomniak in forum C Programming
    Replies: 2
    Last Post: 03-15-2003, 04:54 PM
  5. optimizing bubble sort
    By Sargnagel in forum C Programming
    Replies: 14
    Last Post: 01-23-2003, 06:27 AM