Merge Sort is an example of a sorting algorithm that uses the Divide and Conquer paradigm. What is its time complexity in the worst-case scenario?मर्ज सॉर्ट एक छँटाई एल्गोरिथ्म का एक उदाहरण है जो विभाजन और विजय प्रतिमान का उपयोग करता है। सबसे खराब स्थिति में इसकी समय जटिलता क्या है?
मर्ज सॉर्ट एक छँटाई एल्गोरिथ्म का एक उदाहरण है जो विभाजन और विजय प्रतिमान का उपयोग करता है। सबसे खराब स्थिति में इसकी समय जटिलता क्या है?
Show answerHide answer
Correct answer: (B) O(n log n)ओ (एन लॉग एन)
Explanation
Merge sort always splits the array in half and merges in linear time: T(n) = 2T(n/2) + n = O(n log n) in the best, average and worst case.Merge sort हमेशा array को आधा बाँटता है और रैखिक समय में merge करता है: T(n) = 2T(n/2) + n = O(n log n), सर्वोत्तम, औसत और सबसे खराब, तीनों स्थितियों में।