recategorized by
314 views

1 Answer

2 votes
2 votes

Choose the median in constant time, because the algorithm is implemented as an array and you can find the median in constant time.

Then, split the array with respect to the median.

The recurrence relation will be:

T(n) = 2T($\frac{n}{2}$) + 1

(1 because we are doing a constant work and then splitting the array)

Solve by master's theorem, you will get $\Theta (n)$

NOTE: If the data structure used was a linked list or if the elements were not in ascending order, the complexity would have been $\Theta (nlogn)$

edited by

Related questions

0 votes
0 votes
0 answers
1
Rajat Agrawal007 asked Dec 6, 2021
384 views
Given AVL tree is originally balanced. If a node is added to T1 so that height T1 becomes h+1 from h and z is the first node which is now imbalanced, Then find the height...
2 votes
2 votes
3 answers
2