Algorithms and Data Structures · Senior · Question 23 of 75

By the master theorem, what is the complexity of T(n) = 2T(n/2) + O(n)?

Explanation

Two halves with linear work to combine is the merge sort recurrence. Each of the log n levels of recursion does O(n) work in total. T(n) = 2T(n/2) + O(1) would be O(n), and T(n) = T(n/2) + O(1) is binary search, O(log n).

Further reading

Problem with a question

Algorithms and Data Structures · Senior · question 23

Test yourself

Take the Algorithms and Data Structures · Senior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz