The Gateway to Computer Science Excellence
+1 vote
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
in Algorithms by | 166 views

1 Answer

+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 :


Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
52,315 questions
60,427 answers
95,235 users