Answers ( 2 )

  1. 2017-01-05 16:01

    The comparison function must meet the requirements of Compare concept. One of the requirements is:

    If comp(a,b)==true then comp(b,a)==false

    Your function violates this requirement, so the program has undefined behaviour.

  2. 2017-01-05 17:01

    You write qsort by taking an item at random, then separating all the input into "bigger" and "smaller" piles. Then you do the same to both of the piles. It only works if you more or less halve each pile on each step. If the comparison function always returns true, everything goes into the "bigger" pile, and thus the recursion never stops until the stack is exhausted and the computer reports an error.

    That's probably what is happening.

◀ Go back