1
$\begingroup$

I want to sort first $\sqrt n$ minimum of an array of n elements. What is the time complexity? My approach is : First I have to find the $\sqrt n$ 'th minimum element (name it $x$) which has the time complexity of : $$O(n)$$ Second I have to make $x$ as pivot to place lower elements before $x$ using Partition algorithm which have time complexity of: $$O(n)$$ And then I have to sort these $\sqrt n$ elements using a sort algorithm that has minimum time complexity of: $$O(\sqrt n \times log(n))$$ So the total time complexity should be: $$O(n)$$ but the textbook has the answer of: $$O(\sqrt n \times log(n))$$ I do not know why ? does it mean that: $$n \in O(\sqrt n \times log(n))$$ Or I have mistake in my solution? Best Regards

  • 2
    Looks like typo in textbook, because you must read all array => complexity is not less $O(n)$2017-02-05
  • 0
    Is my approach for 3 steps correct?2017-02-05
  • 0
    IMHO, it is correct2017-02-05

0 Answers 0