-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
The "median_of_three_pivot" function isn't working properly. There are 3 problems with this function:
1. Incorrect loop nesting:
The for i in range(3): outer loop is unnecessary — you only need to compare the three values once to find the median. But within it, you also redefine counts and run comparisons that make no sense when nested this way.
2. Redundant and incorrect logic with counts:
The counts mechanism for identifying the median is overcomplicated and misused. For three elements, you can simply sort them based on value and pick the one in the middle.
3. Premature return statement:
The return pivot is inside the outer loop, which will exit the function after the first iteration, not allowing the rest of the logic to execute properly.
Metadata
Metadata
Assignees
Labels
No labels