let Sort1 be a given algorithm and A a given array. Sort1 run in time of f(n). I need to create a new stable algorithm, Sort2, using Sort1 that will run in time of f(n)+O(n).
I have a solution my friend suggested:
is his solution right? do you have any suggestions? thanks!
Make your copy, but then create a new comparison function that uses the original data as the primary key (probably even using the original comparison function to do the comparison), and if that's equal, have it do a secondary comparison based on the original position in the array.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With