reset password
Author Message
ebayazi
Posts: 29
Posted 00:43 Mar 20, 2013 |

According to the Book (p.249) Selection sort finds the smallest number in the list and swaps it with the first element but in the lecture mentioned find the largest number and swap it with the last !!!  Do you guys have any idea about this?

kknaur
Posts: 540
Posted 10:52 Mar 20, 2013 |

They are two versions of the same thing.  Selection sort can be implemented to work in either case.  You can sort using the smallest element and then swapping with the first, or you can sort using the largest element and swapping with the last.  For the exam, you have to take whichever algorithm I give you and follow it very carefully.  Don't make any assumptions about how you think the sorting should work.  Just follow the code exactly.