Sorting Summary - Getting Started / Basic Algorithms

https://algo.monster/problems/sorting_summary

“On the other hand, because the number of swaps between elements is minimal (O(n)), it is suitable for sorting when the swapping speed is very slow.” - What does “it” refers to here? Selection sort?

can someone clarify this statement ? I am finding it confusing as well.

Because selection sort only swaps 1 element per cycle (picks the smallest and puts at top of list), instead of how bubble/insertion sort make many swaps per cycle, its beneficial to use selection sort if your swapping speed is slow and your iterating over array speed is faster. Though i’m not sure when would this scenario happen in real life. Maybe on certain hardware types?

Merge Sort can be a in place sort instead of creating subarray. I think is missing this.

And what about cycle sort. This approach can be used in questions like elements between 1-N and 0-N and can be sorted in o(n) time.

"Insertion sort and bubble sort are both stable, so they are helpful in situations where stability is essential, like sorting lines of excel sheets by one column.

On the other hand, because the number of swaps between elements is minimal (O(n)), it is suitable for sorting when the swapping speed is very slow."

Sorry, which of the sorts is “it” referring to here?

haven’t heard about it until now. it’s nice to know but I don’t think you’d need it for interviews.

in-place merge sort is very hard to implement and is more of the topic of academic research. I wouldn’t worry about it for interviews. It may even confuse less technical interviewers XD

https://en.wikipedia.org/wiki/Merge_sort#In-place_merge_sort

“A problem with the above quick sort implementation” I could not find the quick sort implementation, is it covered anywhere?

1 Like

Where is the editor that the page says is at the top of the page? I am using Safari browser and don’t see it. Am I missing something?

1 Like

I have the same question. Not seeing any editor here.

1 Like