-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exercise 4.3-5 #452
Comments
Also how is it true that the third and fourth lines of the solution are equal? Where does the $ -4c $ term come from in the fourth line of the solution (second line here)? Additionally, it is stated that the last step in the solution hold for $ c > d $, I believe this should be $ c \ge d $ |
Between the issues previously mentioned I think the solution would be better written as the following. For $ O(n\lg n) $, we guess Where the last step holds for $ c \ge d $. We can go from line 1 to line 2 because $ (n/2+1) \ge \lceil n/2 \rceil, \lfloor n/2 \rfloor $ |
If the recurrence relation is $$ T(n) = T(\lceil n / 2 \rceil) + T(\lfloor n / 2 \rfloor) + \Theta(n) $$
And our inductive hypothesis for the upper bound is $$ T(n) \le c(n-2)\lg(n-2) -2c $$
Then the first line of the solution should be $$ T(n) \le c(\lceil n / 2 \rceil -2 )\lg(\lceil n / 2 \rceil - 2) \textbf{ -2c } + c(\lfloor n / 2 \rfloor - 2)\lg(\lfloor n / 2 \rfloor - 2) \textbf{ -2c } + dn $$
Instead of $$ T(n) \le c(\lceil n / 2 \rceil -2 )\lg(\lceil n / 2 \rceil - 2) + c(\lfloor n / 2 \rfloor - 2)\lg(\lfloor n / 2 \rfloor - 2) + dn $$
Note that the second line of the solution is correct as it has the two $ -2c $ terms, it is only the first line that is incorrect.
The text was updated successfully, but these errors were encountered: