Computer Science, asked by Sawaid30211, 1 year ago

What is the time complexity for executing merge sort on an array of size n which is already sorted is

Answers

Answered by shivanshusingh97
2

When x is not present, the search() functions compares it with all the elements of arr[] one by one. Therefore, the worst case time complexity of linear search would be Θ(n). In average case analysis, we take all possible inputs and calculate computing time for all of the inputs.

Answered by Anonymous
5

O(nlogn) is the time complexity for executing merge sort on an array of size n which is already sorted.

  • Time complexity of merge sort for all the three scenarios i.e. best , average, worst case scenario is same.
  • The basic idea for merge sort suggests that it'll divide an array into smaller and smaller arrays , sort them separately and then merge them.

Similar questions