570 views
1 votes
1 votes
is it quick sort is inplace algorithm.  according to me it takes o(logn) space in best case and as i know any algo takes more then 0(1)  spcae  count as  not inplace algo then why quick sort is inplace plz explain  clearly

1 Answer

2 votes
2 votes

Any algorithm is in place if it does not need additional auxillary space for data structure and its input is transformed by swapping with some operations.

However a small amount of extra storage space is allowed for auxiliary variables.

Quicksort operates in-place on the data to be sorted. However, quicksort requires O(log n) stack space pointers to keep track of the subarrays in its divide and conquer strategy. Consequently, quicksort needs O(log2 n) additional space. Although this non-constant space technically takes quicksort out of the in-place category, quicksort and other algorithms needing only O(log n) additional pointers are usually considered in-place algorithms. 

Most selection algorithm are also in-place

u can refer : https://en.wikipedia.org/wiki/In-place_algorithm

Related questions

0 votes
0 votes
3 answers
2
ajaysoni1924 asked Sep 2, 2019
3,469 views
In quick sort for sorting of n Numbers, the 75th greatest Element is selected as pivot using $O(n^2)$ time complexity algorithm than what is the worst case time complexit...