diff options
-rw-r--r-- | quick-sort.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/quick-sort.cpp b/quick-sort.cpp index 4e560a9..8e54ca7 100644 --- a/quick-sort.cpp +++ b/quick-sort.cpp @@ -10,6 +10,9 @@ typedef std::deque<int> list_t; size_t partition(list_t& lst, size_t left, size_t right, size_t pivot) { + if (left == right) + return left; + list_t::value_type pivot_val = lst[pivot]; swap(lst[pivot], lst[right]); // move pivot to end. size_t store_pos = left; |