![Page 1: As an example of developing a complete program, today we ...reactorlab.net/resources-folder/matlab/pdf-link-folder/bb_20180824.pdfSorting AlgorithmsAnimations The following animations](https://reader034.vdocument.in/reader034/viewer/2022042313/5edca232ad6a402d6667621c/html5/thumbnails/1.jpg)
As an example of developing a complete program, today we write a “selection sort” algorithm.See Chapter 8.
Sorting is very important. For example, it is used in Google’s indexing of web sites to speed searches
See this web simulation of sorting algorithms https://www.toptal.com/developers/sorting-algorithms
![Page 2: As an example of developing a complete program, today we ...reactorlab.net/resources-folder/matlab/pdf-link-folder/bb_20180824.pdfSorting AlgorithmsAnimations The following animations](https://reader034.vdocument.in/reader034/viewer/2022042313/5edca232ad6a402d6667621c/html5/thumbnails/2.jpg)
Ready to click “Play All” next
![Page 3: As an example of developing a complete program, today we ...reactorlab.net/resources-folder/matlab/pdf-link-folder/bb_20180824.pdfSorting AlgorithmsAnimations The following animations](https://reader034.vdocument.in/reader034/viewer/2022042313/5edca232ad6a402d6667621c/html5/thumbnails/3.jpg)
THESE HAVE ALREADY FINISHEDPART WAY THROUGHTHE SORT
![Page 4: As an example of developing a complete program, today we ...reactorlab.net/resources-folder/matlab/pdf-link-folder/bb_20180824.pdfSorting AlgorithmsAnimations The following animations](https://reader034.vdocument.in/reader034/viewer/2022042313/5edca232ad6a402d6667621c/html5/thumbnails/4.jpg)
I often start with sketching and outlining the problem on a piece of paper.
Here, we start working on the “Selection Sort” algorithm
In the next slides, we use “temp” instead of “a” for the swap variable name
![Page 5: As an example of developing a complete program, today we ...reactorlab.net/resources-folder/matlab/pdf-link-folder/bb_20180824.pdfSorting AlgorithmsAnimations The following animations](https://reader034.vdocument.in/reader034/viewer/2022042313/5edca232ad6a402d6667621c/html5/thumbnails/5.jpg)
start by outlining with comments, write a line or two, then test
![Page 6: As an example of developing a complete program, today we ...reactorlab.net/resources-folder/matlab/pdf-link-folder/bb_20180824.pdfSorting AlgorithmsAnimations The following animations](https://reader034.vdocument.in/reader034/viewer/2022042313/5edca232ad6a402d6667621c/html5/thumbnails/6.jpg)
In order to do more scans of the vector, weneed to make this into a variable… this is also aproblem if v(1) is the lowest value since lowValue andlowVindex will be unknown variables in the fprintf’s
![Page 7: As an example of developing a complete program, today we ...reactorlab.net/resources-folder/matlab/pdf-link-folder/bb_20180824.pdfSorting AlgorithmsAnimations The following animations](https://reader034.vdocument.in/reader034/viewer/2022042313/5edca232ad6a402d6667621c/html5/thumbnails/7.jpg)
![Page 8: As an example of developing a complete program, today we ...reactorlab.net/resources-folder/matlab/pdf-link-folder/bb_20180824.pdfSorting AlgorithmsAnimations The following animations](https://reader034.vdocument.in/reader034/viewer/2022042313/5edca232ad6a402d6667621c/html5/thumbnails/8.jpg)
![Page 9: As an example of developing a complete program, today we ...reactorlab.net/resources-folder/matlab/pdf-link-folder/bb_20180824.pdfSorting AlgorithmsAnimations The following animations](https://reader034.vdocument.in/reader034/viewer/2022042313/5edca232ad6a402d6667621c/html5/thumbnails/9.jpg)
convert some more numeric constantsto variables
![Page 10: As an example of developing a complete program, today we ...reactorlab.net/resources-folder/matlab/pdf-link-folder/bb_20180824.pdfSorting AlgorithmsAnimations The following animations](https://reader034.vdocument.in/reader034/viewer/2022042313/5edca232ad6a402d6667621c/html5/thumbnails/10.jpg)
Now, repeat scanning the vector
![Page 11: As an example of developing a complete program, today we ...reactorlab.net/resources-folder/matlab/pdf-link-folder/bb_20180824.pdfSorting AlgorithmsAnimations The following animations](https://reader034.vdocument.in/reader034/viewer/2022042313/5edca232ad6a402d6667621c/html5/thumbnails/11.jpg)
now that we are done, we can comment the rng lineand get a new vector each run