The worst-case time complexity of heapsort is ___________.
- O(log n)
- O(n log n)
- O(n)
- O(n^2)
The worst-case time complexity of heapsort is O(n log n). Heapsort involves two main operations: building a heap (heapify) and repeatedly removing the maximum (for a max heap) or minimum (for a min heap) element. Both of these operations have a time complexity of O(n log n) in the worst case, resulting in heapsort also having a worst-case time complexity of O(n log n). This makes heapsort an efficient sorting algorithm for large datasets.
Loading...
Related Quiz
- The ________ layer of the OSI Model is responsible for segmenting data and ensuring its reliable delivery.
- In an e-commerce application, you're tasked with optimizing database queries to display product recommendations based on user preferences. How would you approach this problem using RDBMS concepts?
- Git _________ is a technique used to combine multiple commits into one.
- The ___________ layer in the TCP/IP model is responsible for logical addressing.
- What are the applications of trees in real-world scenarios?