Skip to content

Commit 19f318b

Browse files
authored
Updated Heap-Sort.md
1 parent e3058b0 commit 19f318b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

dsa-solutions/Sorting-Algorithms/Heap-Sort.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -275,18 +275,18 @@ function sort( arr)
275275

276276
## 8. Complexity Analysis
277277

278-
- Time Complexity: O(N log N)
279-
- Auxiliary Space: O(log n), due to the recursive call stack. However, auxiliary space can be O(1) for iterative implementation.
278+
- Time Complexity: $O(N log N)$
279+
- Auxiliary Space: $O(log n)$, due to the recursive call stack. However, auxiliary space can be $O(1)$ for iterative implementation.
280280

281281
## 9. Advantages and Disadvantages
282282

283283
**Advantages:**
284-
- **Efficient Time Complexity**: Heap Sort has a time complexity of O(n log n) in all cases. This makes it efficient for sorting large datasets. The log n factor comes from the height of the binary heap, and it ensures that the algorithm maintains good performance even with a large number of elements.
284+
- **Efficient Time Complexity**: Heap Sort has a time complexity of $O(n log n)$ in all cases. This makes it efficient for sorting large datasets. The log n factor comes from the height of the binary heap, and it ensures that the algorithm maintains good performance even with a large number of elements.
285285
- **Memory Usage** – Memory usage can be minimal (by writing an iterative heapify() instead of a recursive one). So apart from what is necessary to hold the initial list of items to be sorted, it needs no additional memory space to work
286286
- **Simplicity** – It is simpler to understand than other equally efficient sorting algorithms because it does not use advanced computer science concepts such as recursion.
287287

288288
**Disadvantages:**
289-
- **Costly**: Heap sort is costly as the constants are higher compared to merge sort even if the time complexity is O(n Log n) for both.
289+
- **Costly**: Heap sort is costly as the constants are higher compared to merge sort even if the time complexity is $O(n Log n)$ for both.
290290
- **Unstable**: Heap sort is unstable. It might rearrange the relative order.
291291
- **Efficiency**: Heap Sort is not very efficient when working with highly complex data.
292292

0 commit comments

Comments
 (0)