Question
Which of the following sorting algorithms has a worst-case time complexity of O(N log
- N ?
Solution
Merge Sort consistently achieves O(N log N) time complexity in its best, average, and worst cases because it always divides the array into two halves and then merges them. Bubble Sort, Selection Sort, and Insertion Sort have O(N^2) worst-case complexity. Quick Sort has an average-case O(N log N) but a worst-case O(N^2) if the pivot selection is consistently poor.
More Algorithms Questions
- Which algorithm guarantees the shortest path in a graph with negative weights but no negative cycles?
- Which layer of the OSI model is responsible for providing end-to-end communication services and ensures complete data transfer?
- Which algorithm is used to detect cycles in a directed graph?
- What is the primary role of a hypervisor in a virtual machine (VM) environment?
- In a Data Analytics pipeline, which of the following is an advantage of using Dimensional Modelling?
- Which of the following is an example of inheritance in OOP?
- What is normalization in the context of databases?
- In which traversal strategy does the algorithm explore all the neighbor nodes at the present depth prior to moving on to nodes at the next depth level?ย ย ...
- Which architecture allows multiple processors to share memory and work simultaneously?ย ย ย ย ย ย
- Which sorting algorithm divides the array into halves recursively?