Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions notes/sorts.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ void mergeSort(array, lo, hi)
merge(array, lo, mid, hi)

void merge(array, lo, mid, hi)
int i = lo, j = hi
int i = lo, j = mid + 1
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is correct.

for (int k = lo; k <= hi; k++)
temp[k] = array[k]
for (int k = lo; k <= hi; k++)
Expand Down Expand Up @@ -41,8 +41,8 @@ int partition(array, lo, hi)
int i = lo
for (int j = lo; j < hi; j++)
if (array[j] <= pivot)
swap(array[i], array[j])
swap(array, i, j)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is pseudocode, your update makes this less readable. Remove this change.

i++
swap(array[i], array[hi])
swap(array, i, hi)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is pseudocode, your update makes this less readable. Remove this change.

return i
```