Re: visualisation a programme.

I think its more important to understand how selection sort works at a conceptual level. If you have that, then the implementation in source code follows naturally.

Suppose you have the following list of numbers: 5, 8, 1, 4, 9, and you want to sort them in ascending order.

The idea behind selection sort is to first look at the array, and see which number is the smallest. Once you find this number, swap it with the first number. In this case, 1 is the smallest number, and swappling it with 5 results in the following: 1, 8, 5, 4, 9

You can now divide the array into 2 parts: the first element, 1, is the list of sorted items you have so far. The rest of the array is the unsorted list. You next repeat this process.

The smallest number in the unsorted list is now 4. Swap it with 8 to get the following: 1, 4, 5, 8, 9

The sorted list is now 1 and 4, with the rest of the array yet to be sorted. You should be able to continue repeating the process till the enti re array is sorted. Its called selection sort because in each iteration, you select the smallest number to be swapped.

_______________________________________________
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Ishan Dhami via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Victorious via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Ishan Dhami via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Victorious via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Ishan Dhami via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Victorious via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Ishan Dhami via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Ishan Dhami via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Victorious via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Ishan Dhami via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Victorious via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Ishan Dhami via Audiogames-reflector

Reply via email to