Why Merge Operation in Merge Sort is O(n)?
问题 For merge-sort divide and conquer operations, how much time is required in bottom up merging phase? My instructor says that it is be linear, hence it will be O(n) . But I didn't get it. How will it be linear? How will merging operation be linear O(n) ? 回答1: Merge operation of two arrays, is scanning arrays and picking the lowest/highest of two. so you have a: [1, 3, 6, 7] b: [4, 5, 7, 8] you compare like this (sort of pseudo code) indexA = 0; indexB = 0; auxilaryArray = []; indexAux = 0;