Answer the question
In order to leave comments, you need to log in
Is it true that the more “scattered” an array of numbers is, the longer it will take to sort it (say, with a bubble)?
Let's say if I sort 2 separate arrays, then merge them into one by adding elements of one between the elements of the other (like braiding a pigtail), and then sort the resulting array again, then this last sort will take less time than if I initially had 1 array?
If you don't feel like answering the second question, answer the first.
Answer the question
In order to leave comments, you need to log in
For bubble sort
For the above approach (separately sort the parts then merge), merge-sort is used.
1. In general, no.
2. Maybe yes, maybe not. Strongly depends on the used algorithm and elements of arrays.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question