## dexter4life Group Title how does the selection sort algorithm works? 2 years ago 2 years ago

1. agdgdgdgwngo Group Title

It works by passing through the the sequence n-1 times, working its way up the sequence. In each pass, it looks for the smallest element in the sequence (say I'm sorting in ascending order), storing it in a register. Once the pass is complete, it swaps the smallest element with the element in the current index and moves on.

2. agdgdgdgwngo Group Title

http://www.youtube.com/watch?v=t8g-iYGHpEA selection sort is in there

3. Neeraj_OCW Group Title

Click on the green icon on top-left of this page http://www.sorting-algorithms.com/selection-sort It'll start visualizing the lines below which describes the how sorting is going on. There are also other visualizations for diff. alogs.

4. dexter4life Group Title

Base on the O(n). Where does the selection sort falls. Is it O(nlogn) or ?

5. dexter4life Group Title

$O(nLogn)$

6. dexter4life Group Title

Please some body explain this for me --> O(nLogn).

7. Neeraj_OCW Group Title

Ok, i asked this question a few back on CS.SE, it's better you have a look at all answers there than i explain http://cs.stackexchange.com/questions/192/how-to-come-up-with-the-runtime-of-algorithms

8. agdgdgdgwngo Group Title

Actually, selection sort is $$O\left(n^2\right)$$