Swapping in Selection Sort

Hello Sir/Mam,

Why Prateek bhaiya said that “Swapping is an expensive operation” in the video of selection sort at 6:45 min in the Arrays section?

Thank You

hi @shubhamdeepjha, since swapping has at minimum two operation with memory access thus it is more expensive than some elemental operations . in sorting algo’s like bubble sort we have rapid comparisons and swapping making it more expensive than algo’s like selection sort
refer this :- https://cs.stackexchange.com/questions/13106/why-is-selection-sort-faster-than-bubble-sort for some insight on runtime differences

In case of any doubt feel free to ask :slight_smile:
If you got the answer then mark your doubt as resolved

Thank you sir, I understood what you said.

great !! in case of any further doubts feel free to ask :slight_smile: