0
$\begingroup$

How we can prove that the largest element in a min-heap using a comparison-based algorithm takes Ω(logn) time?

Is this useful that worst running time for comparison based sorting is >= longest path from root to leaf = height of the tree >= log(n!) = Ω(logn)?

asked Mar 4, 2024 at 11:20
$\endgroup$
2
  • 1
    $\begingroup$ Otherwise you could sort in $o(n \log n)$ time. $\endgroup$ Commented Mar 4, 2024 at 11:37
  • 1
    $\begingroup$ Please rewrite your question and be more precise. "the largest element [...] takes $\Omega(\log n)$ time" is not a valid statement. $\endgroup$ Commented Mar 4, 2024 at 11:39

2 Answers 2

0
$\begingroup$

Is this useful that worst running time for comparison based sorting is >= longest path from root to leaf = height of the tree >= log(n!) = Ω(logn)?

It is useful if we interpret $\log n!$ as $n \log n$.

How we can prove that the largest element in a min-heap using a comparison-based algorithm takes Ω(logn) time?

It is possible if we interpret the operation as extracting instead of returning.

Extracting $n$ elements is equivalent to sorting $n$ elements, if sorting $n$ elements runs in $n \log n$ then sorting an element runs in $\log n$.

answered Mar 4, 2024 at 13:32
$\endgroup$
0
$\begingroup$

Probably you meant to extract the element. Also we are using a min-heap, so I would suppose you wanted to extract the smallest element, but the argument works for both.

Suppose you can extract minimal element from a binary min-heap in time $o(\log n)$. I claim that you can sort in time $o(n\log n)$, which contradicts a well known fact that in comparison based model sorting cannot be done faster than $O(n\log n)$.

Take elements $x_1,\ldots, x_n$, build a min-heap from them in time $O(n)$, then call extract_min $n$ times and append the minima to an auxiliary array. Observe that the last step takes $o(n\log n)$ time and the elements $x_i$ are sorted in the auxiliary array. Thus, you managed to sort in $o(n\log n)$ time which is impossible.

answered Mar 12, 2024 at 18:40
$\endgroup$

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.