QuickSort to sort Mergesort parts?

Ques: Mergesort divides the list of numbers into two halves and calls itself recursively on both of them. Instead, can you perform quicksort in the left half and combine in the right half? If so, show how it will sort the next list of numbers, showing each step. If not, explain why you cannot.

It is assumed that I should sort the list of numbers using mergesort. Where should the left half be sorted using quick sort?

I get it. Answer: Yes, we can

  • Sort the right half of an array using mergesort.
  • Sort the left half using quick sort.
  • Combine 2 using the merge_sort function merge_sort.
+4
source share
2 answers

Yes you can do it. The main idea of ​​mergesort is as follows:

  • Divide the array into two (or more) parts.
  • Sort each part independently.
  • Use the merge step to combine the sorted fragments into one common sorted list.

, , , (2). , , , . mergesort (2), , , . (, mergesort , , ). ​​

, quicksort mergesort . , , , , . , : ( ), . , . .. :

  • , , .., .
  • , , , , ..

, . , , , .: -)

0

, . , " ". , , . . , (, , ) . , .

, , . - , . , , .

0

All Articles