Total number of comparisons required to merge sorted files?

If you assume that you use the merge step from a typical merge sort, that means you can only merge 2 lists at a time, which makes things simpler. We need at least 3 merges to turn 4 lists into 1. We could split up lists, but that's throwing away information and we'll only have to merge them back eventually, so I doubt that helps (without proving it).

Each step when need to know current smallest element among the 4 files. In other word, we need to know the smallest one of the four elements a, b, c, d. So a naive way would use three comparison for each step(a and b, c and d, the smaller of ab and cd).

So the overall comparison would be 3*N (N is the total number of records).

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions