it will be,

T(n) = T(n-1) + O(n)

T(n) = T(n-1) + O(n)

The Gateway to Computer Science Excellence

0 votes

If the array is already sorted and we are using fixed partition method quick sort, then the partition takes place in such a way that one side of the pivot contains n-1 elements and other side contains 0 elements and pivot is in the correct position that gives recurrence as

T(n)=T(n-1)+n

T(n)=T(n-1)+n

0

It does not matter if it is reverse sorted or sorted.If you are choosing the pivot as the last element in either of these cases your sub-problem size shall be T(0) and T(n-1).

https://www.khanacademy.org/computing/computer-science/algorithms/quick-sort/a/overview-of-quicksort

- All categories
- General Aptitude 1.9k
- Engineering Mathematics 7.5k
- Digital Logic 2.9k
- Programming and DS 4.9k
- Algorithms 4.3k
- Theory of Computation 6.2k
- Compiler Design 2.1k
- Databases 4.1k
- CO and Architecture 3.4k
- Computer Networks 4.1k
- Non GATE 1.5k
- Others 1.5k
- Admissions 595
- Exam Queries 576
- Tier 1 Placement Questions 23
- Job Queries 72
- Projects 17

50,647 questions

56,492 answers

195,439 comments

100,708 users