Insertion sort for linked list

we are creating a new head and adding elements in it in a sorted manner…isn’t this way of doing takes extra space equal to size of list ?
if yes how to do inplace ?

Hi @Shubham-Singh-1843190805727785, you must be knowing the classical insertion sort. In that we used 2 iterators i and j. Just replace them with 2 pointers. This was a hint. Pls try to make the algo again now.

Hope this helps :slight_smile:

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.