수정된 MergeSort 런타임 (Modified MergeSort runtime)


문제 설명

수정된 MergeSort 런타임 (Modified MergeSort runtime)

수정된 MergeSort 알고리즘의 런타임을 이해하도록 도와주세요. 고전적인 MergeSort에서 입력 배열을 두 부분으로 나누고 재귀적으로 정렬할 때 실행 시간은 다음과 같습니다. nlogn

입력 배열을 세 부분( 절반이 아님), 3분의 1마다 재귀적으로 정렬하고 마지막으로 3개의 인수로 구성된 병합 병합 하위 프로그램을 사용하여 결과를 병합합니다.

  1. n
  2. nlogn
  3. n (로그 n) ^ 2
  4. n ^ 2로그n

참조 솔루션

방법 1:

In the classic Merge Sort algorithm, there are approximately n * log2(n) comparisons and as many element copy operations, hence the time complexity of O(n.log(n)) because multiplicative constants are implicit.

If instead of splitting the array into 2 parts, you split into 3 parts, perform the same sort recursively on the parts and merge the 3 sorted slices into one, the number of comparisons increases to approximately 2 * n * log3(n) and the number of element copies is reduced to n * log3(n), but both are still proportional to n * log(n). Factoring out multiplicative constants, you still get a time complexity of O(n.log(n)).

(by richardRchqrlie)

참조 문서

  1. Modified MergeSort runtime (CC BY‑SA 2.5/3.0/4.0)

#mergesort #Sorting #algorithm






관련 질문

파이썬에 대한 병합 정렬(잘못된 것을 찾을 수 없음) (Merge Sort in place for python (Cant find what is wrong))

두 가지 빠른 수정 문제 - 병합 정렬 (two quick fix issues - Merge Sort)

Java로 작성된 병합 정렬 프로그램이 작동하지 않습니까? (My merge sort program written in Java is not working?)

MergeSort 문제: "... VariableDeclaratorId"가 FormalParameterList를 완료합니다. (MergeSort Issues: "... VariableDeclaratorId" to complete FormalParameterList)

크기가 16인 배열로 병합 정렬의 복잡성을 찾는 방법 (how can we find the complexity of merge sort with an array of size 16)

Java 병합 정렬의 정렬 부분 이해 (Understanding the sort part of Java Merge sort)

이 재귀가 기본 사례를 얻지 못하는 이유는 무엇입니까? (Why is this Recursion not getting its base case?)

Java 오류: java.lang.IllegalArgumentException: 비교 방법이 일반 계약을 위반함 (Java Error: java.lang.IllegalArgumentException: Comparison method violates its general contract)

수정된 MergeSort 런타임 (Modified MergeSort runtime)

내 병합 정렬 프로그램이 Java에서 범위를 벗어난 배열을 보여줍니다. (My merge sort program shows an array out of bound in Java)

Array Merge sort Sorting Count and Sorting time Python (Array Merge sort Sorting Count and Sorting time Python)

병합 정렬을 사용하여 연결 목록 정렬에 대한 오답 얻기 (Getting wrong answer for sorting linked list using merge sort)







코멘트