jeffgerickson / algorithms

Bug-tracking for Jeff's algorithms book, notes, etc.
7.92k stars 1.02k forks source link

[Oops.] May be there is a error in Page 28 #178

Open voook opened 5 years ago

voook commented 5 years ago

Please verify that the error is present in the most recent revision before reporting. 1st edition

Chapter number or note title: [title] 1.4 mergesort Correctness

Page number: [page] Page 28

Error description: [error]

First paragraph at Page 28

Proof: Let A[1 .. n] be any array and m any integer such that the subarrays A[1 .. m] and A[m + 1 .. n] are sorted. We prove that for all k from 0 to n, the last n − k − 1 iterations of the main loop correctly merge A[i .. m] and A[ j .. n] into B[k .. n]. The proof proceeds by induction on n − k + 1, the number of elements remaining to be merged.

I think "We prove that for all k from 0 to n, the last n − k − 1 iterations of the main loop correctly" has a error: We prove that for all k from 0 to n, assumed that k is 0 and n is 0, so n - k - 1 is -1( -1 ?)

In my opinion It should be k is 0 and n is 0, so n - k + 1 is 1. Suggested fix (if any): [fix]

Suggested fix:

change

"We prove that for all k from 0 to n, the last n − k − 1 iterations of the main"

to

"We prove that for all k from 0 to n, the last n − k + 1 iterations of the main"

echuber2 commented 5 years ago

This seems to be the same issue as #169

voook commented 5 years ago

@echuber2 Yes,you are right.Sorry, I didn't notice that.