79585157

Date: 2025-04-21 19:06:10
Score: 0.5
Natty:
Report link

I need to update the midpoint variable to "chase" the midpoint value if the midpoint gets swapped:

uint partition(Tester &tester, uint start, uint end) {
    uint midpoint = (start + end) >> 1;
    for (;;) {
        while (tester.compare(start, midpoint) < 0)
            ++start;
        while (tester.compare(midpoint, end) < 0)
            --end;
        if (start >= end)
            return end;
        if (midpoint == start)
            midpoint = end;
        else if (midpoint == end)
            midpoint = start;
        tester.swap(start++, end--);
    }
}
Reasons:
  • Blacklisted phrase (0.5): I need
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: user22200698