PREV INDEX NEXT

Author: Unknown
Subject: 2 * # of compares + N constraint
Date: Tuesday, 17 Mar 2020, 16:18:27

According to the walkthrough, 2 * (# of compares) is equivalent to M where M is the number of elements being partitioned in the call.

When doing the partition step in a quicksort of a set of N items, doesn't that take N-1 number of compares as we have to compare every element besides the pivot to the pivot? Shouldn't 2 * (# of compares) actually be 2 * (M-1) instead of simply M as stated in the walkthrough?
PREV INDEX NEXT