Is stable and in-place the same?
algorithm, sorting
Solution
No,
Stable algorithm means that the relative ordering of 'equal' elements shall remain same after the algorithm is executed.
For instance, if you have an array
{-2, 4, 5, -11, 9, -10}
and you want to sort it such that all negative elements come before the positive elements. And you want the relative ordering of -ve and +ve elements remain the same
{-2, -11, -10, 4, 5, 9}
This is the output of a stable algorithm
As noted in the comments, in place algorithm means the algorithm does not require additional space other than the input data. The output is data occupies the same place in memory that was occupied by the input data and the input data gets destroyed.
Problem
When talking about algorithms. I see description of both in-place and stable sorting algorithms. Is saying a algorithm is stable the same as saying its in-place? if not what is the difference?