I use recursive merge sort for sorting a link list, but during the merge sort I would like to delete duplicates. Anyone has insight in how to accomplish this?
I am using C code.
In merge sort you take two (or more) already-sorted lists repeatedly apply the following rules:
To remove duplicates, you simply modify the rules very slightly:
This will ensure that no two consecutive items on your output list are the same, and that the items in it are in order, which is what you were after.
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