Skip to content
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

2.1.c #473

Open
FXTY opened this issue Apr 4, 2023 · 1 comment
Open

2.1.c #473

FXTY opened this issue Apr 4, 2023 · 1 comment

Comments

@FXTY
Copy link

FXTY commented Apr 4, 2023

Θ(nk+nlg(n/k))
=Θ(nk+nlgn−nlgk)
=Θ(nlgn+nlgn−nlg(lgn))
=Θ(2nlgn−nlg(lgn))
=Θ(nlgn).

Why is the penultimate line of the equation equal to the last line of the equation, should it be approximately equal here?

This error seems obvious, assuming n is equal to 16, the second-to-last line of the equation has a value of 128, and the last line of the equation results in 32. If only the highest order item is taken, then the second line of the equation should be directly equal to the last line.

The question here is what is the minimum value of k, here you seem to be directly making an assumption, why do you assume that, and what is the basis for the assumption?

@leverimmy
Copy link
Contributor

From my point of view, the essence lies in solving the equation $$\Theta(nk + n\lg n - n\lg k) = \Theta(n\lg n).$$
By crossing out the irrelevant $n\lg n$ term on the left side, what we really need to solve is $$\Theta(n(k - \lg k)) = \Theta(n\lg n).$$

It is quite intuitive to say that we can also cross out the factor $n$ on both sides, which leads to $\Theta(k - \lg k) = \Theta(\lg n)$. Treat the left side as a function of $k$ instead of $n$, then directly we omit the $\lg k$ term and obtain that $k = \Theta(\lg n)$.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants