Thread: how do u test sorting algorithm stability

  1. #1
    Registered User
    Join Date
    Feb 2005
    Posts
    13

    Unhappy how do u test sorting algorithm stability

    i heard one of the method is using % and / as predicate when compare the elements, but i dont really understand why use % and /, may anyone explan for me, thx very much!

  2. #2
    aoeuhtns
    Join Date
    Jul 2005
    Posts
    581
    1) Take a piece of data.
    2) Take a less-than operator that does not use the entire piece of data in comparing.
    3) Sort using that less-than operator, with some of the data comparing as equal while containing different parts.
    4) Check to see if 'equal' elements' order is preserved.

    For example, have your data be strings, and then sort by the lengths of the strings.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Efficient Sorting Algorithm
    By GCNDoug in forum C++ Programming
    Replies: 10
    Last Post: 11-13-2008, 09:06 AM
  2. Newbie needs help..
    By xpress urself in forum C++ Programming
    Replies: 3
    Last Post: 07-26-2007, 07:22 PM
  3. which sorting algorithm for GBs of data?
    By Sargnagel in forum C Programming
    Replies: 4
    Last Post: 06-05-2003, 08:43 AM
  4. test scores
    By ucme_me in forum C Programming
    Replies: 4
    Last Post: 11-14-2001, 01:48 PM