mergesort - Why is merge sort's worst case still n log n? -
it question on final took earlier , had no idea how answer it.
well was
what merge sort's worst case runtime more importantly, why?
the divide-and-conquer contributes log(n) factor. divide array in half log(n) times, , each time do, each segment, have merge on 2 sorted array. merging 2 sorted arrays o(n). algorithm walk 2 arrays, , walk 1 that's lagging.
Comments
Post a Comment