in merge sort, we always divide the array twice. why dont we divide it more than twice ?? and which is better among heap sort and merge sort ?I
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Why not try it and see. Write a merge sort that splits into 5 pieces instead of 2, and test its performance. The best way to learn is to try.
It has no effect on computational complexity, so the improvement is at most a constant factor. You reduce the number of merge passes by a factor of lg(5) ≈ 2.3, but the merging step now requires a priority queue, which is going to be more than 2.3 times slower than the single comparison used by a two-phase merge.
Dividing into more than 2 pieces is known as polyphase merge sort, and it is used when you need to minimize the number of merge passes.