# Time complexity of quicksort for arrays in increasing or descreasing order

Two $$n$$-size arays are given: $$n_1$$ is in decreasing order and $$n_2$$ is in increasing order.

Let $$c_1$$ be the time complexity for $$n_1$$ using quicksort, and $$c_2$$ the time complexity for $$n_2$$ using quicksort.

I think $$c_1 = c_2$$ and $$c_1=O(n^2)$$? Is this correct ?

I am using the last element as a pivot for each partition.

• The complexity of Quicksort depends on the pivot element that you've chosen. – Gokul Feb 17 at 10:32
• lets say I am choosing last element as a pivot – Manoharsinh Rana Feb 17 at 10:34
• That's a known bad strategy. Don't do that. Now think about how you would sort faster if a reasonable percentage of arrays that you sort are already sorted. – gnasher729 Feb 17 at 11:10
• The question isn't answerable from the information given in your post. The answer depends on how you choose the pivot element. Just saying "quicksort" doesn't fully specify the algorithm you're using. Please edit the question to specify exactly what algorithm you're using. Don't just leave information in the comments; edit the question to make sure that everything that people need to answer is found in the question. – D.W. Mar 7 at 19:44