Merging two files with sorted integers in c

Hi,

I want to merge two files with sorted integers. I want to merge two files to a single file such that there are no duplicates and the merged file should contain the integers in the sorted order. Just some idea or pointer to an implementation will help me a lot.

Thanks & Regards,
brett.

Hello brett,
there are several known algorithms for that purpose. I feel the K-way-merge algorithm is the best one that I have used for that purpose.
In addition to that you can put up a condition to remove the duplicate entries
Or otherwise you can first remove the duplicate entries from the two sources after/before sorting and then implement the K-way merge algorithm .
Feel free to reply if any doubts.
You would like to check this in case

Regards.

If the two files are already sorted, then

sort -mnu file1 file2

otherwise omit the m in the options.

Looks like insertion sort could help with this problem.

Is the key way merge algorithm for already sorted files??