mirror of
https://github.com/krahets/hello-algo.git
synced 2026-08-19 06:50:59 +00:00
Fix multilingual content typos (#1958)
This commit is contained in:
@@ -31,7 +31,7 @@ It's worth noting that **since leaf nodes have no children, they are naturally v
|
||||
|
||||
Next, let's attempt to derive the time complexity of this second heap construction method.
|
||||
|
||||
- Assuming the complete binary tree has $n$ nodes, then the number of leaf nodes is $(n + 1) / 2$, where $/$ is floor division. Therefore, the number of nodes that need heapification is $(n - 1) / 2$.
|
||||
- Assuming the complete binary tree has $n$ nodes, then the number of leaf nodes is $(n + 1) / 2$, where $/$ is floor division. Therefore, the number of nodes that need heapification is $n / 2$.
|
||||
- In the top-to-bottom heapify process, each node can sink at most to a leaf node, so the maximum number of iterations is the height of the binary tree, $\log n$.
|
||||
|
||||
Multiplying these two together, we get a time complexity of $O(n \log n)$ for the heap construction process. **However, this estimate is not accurate because it doesn't account for the property that binary trees have far more nodes at lower levels than at upper levels**.
|
||||
|
||||
Reference in New Issue
Block a user