You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: dsa-solutions/Sorting-Algorithms/Heap-Sort.md
+4-4Lines changed: 4 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -275,18 +275,18 @@ function sort( arr)
275
275
276
276
## 8. Complexity Analysis
277
277
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.
280
280
281
281
## 9. Advantages and Disadvantages
282
282
283
283
**Advantages:**
284
-
-**Efficient Time Complexity**: Heap Sort has a time complexity ofO(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.
285
285
-**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
286
286
-**Simplicity** – It is simpler to understand than other equally efficient sorting algorithms because it does not use advanced computer science concepts such as recursion.
287
287
288
288
**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.
290
290
-**Unstable**: Heap sort is unstable. It might rearrange the relative order.
291
291
-**Efficiency**: Heap Sort is not very efficient when working with highly complex data.
0 commit comments