5

Please check the paper@arXiv2015: A Complete Worst-Case Analysis of Heapsort by M. A. Suchenek. This paper gives a rather involved lower bound; see Abstract and Theorem 12.2 on page 94. To the specific question, Example of a 500-node worst-case array for Heapsort, created by my Java program, is included in Appendix A.3 page 110.


4

The paper: The Analysis of Heapsort by Schaffer and Sedgewick shows that Theorem 1: Heapsort requires that at least $\frac{1}{2} n \lg n - O(n)$ data moves for any heap composed of distinct keys. and that Theorem 3: The average number of data moves required to Heapsort a random permutation of $n$ distinct keys is $\sim n \lg n$. It also mentions ...


3

Both of them will work, and both of them support insertions${}^1$ and deletion${}^2$ of the minimum element in $O(\log n)$ worst-case time (where $n$ is the number of elements currently in the data structure). It really depends what you mean by "better". An AVL tree will have the additional binary-search-tree property that the heaps do not have, and this ...


3

keep in mind, that a heap has a height of $O(\log n)$ and its root contains the minimal element. how long does it take to restore the heap if you remove the root element (the minimum!) and how often you have to do this in order to achieve a sorted list? after that, think of the time you need for building a heap out of $n$ elements in abitrary order


2

HeapSort: A procedure which sorts an array in place. Can be in-place or not in-place, the point is it's using a heap data structure to help sort. Building heap is linear with a careful analysis See more here


2

An algorithm can have worst-case running time that is both $O(n \lg n)$ and $\Omega(n \lg n)$; those don't contradict each other. See How does one know which notation of time complexity analysis to use? and https://cs.stackexchange.com/a/201/755 for some background that might help understand why that is so.


2

Try to solve the recurrent by expanding equality case: $$T(n) = T(2n/3) + \Theta(1) = T(2^2n/3^3) + \Theta(1) + \Theta(1)$$ Now you can see $T(n) = \Theta(\log_{\frac{3}{2}}(n))$. Because each time $\Theta(1)$ is added up to reach to the leaf of the expnasion tree. Also, you can reach this result using the master theorem.


1

No it is not. They both have the same running time but the heap is way lighter for a couple of reasons. For the asymptotic running time, note that a heap can be built in linear time meanwhile applying $n$ operations of extract min takes a total of $O(n \log n)$. On the other hand, constructing an AVL tree requires $O(n\log n)$ operations meanwhile traversing ...


1

So, basically in heap representation, $LEFT(i)$ refers to the index of $i's$ left child. What we want to show is that index $⌊𝑛/2⌋+1$ is a leaf and is not a middleware node which can be proved if we could show the index of the left child is larger than the number of elements in the heap. On the other hand, $LEFT(⌊𝑛/2⌋+1) = 2(⌊𝑛/2⌋+1) = 2⌊𝑛/2⌋+2 $ and ...


1

I suggest reading about the theory on rating systems and ranking systems. There are many standard algorithms and methods for this. I would recommend reading the following resources, to get you started and to give you an entry-point and overview and let you figure out which might be best-suited for your particular situation: The Bradley-Terry model ...


1

Note $$\log (n-1)!\ge \log \frac{n-1}{2}+\cdots+\log (n-1)\ge\frac{n-1}{2}\log \frac{n-1}{2}=\Theta(n\log n).$$


1

Because the analysis is performed assuming that there is a strict total order on the keys. Therefore if you are sorting, for example, integers on their usual order, the lower bound applies only as long as each key is different. If you allow the order to not be strict then the analysis is not particularly interesting, your example is indeed a best case. ...


1

Big O is for measuring the worst case time complexity, and in this case it is $O(n)$. The best case is written as $\Omega$. Here is a paper describing the reasoning for the best case. We generally do not consider the case of having only identical elements in the list.


1

Let $D(i)$ denote the number of descendants of the $i$th node. In a min-heap, all $D(i)$ nodes below node $i$ must have a larger value than node $i$. Hence, the $n-D(i)$ largest values $n-D(i)+1,\ldots,n$ cannot be put in node $i$. It turns out that $n-D(i)$ can be put in node $i$, and so the maximum possible value for node $i$ is $n-D(i)$. To see how ...


Only top voted, non community-wiki answers of a minimum length are eligible