Presentation is loading. Please wait.

Presentation is loading. Please wait.

March 2005 1R. Smith - University of St Thomas - Minnesota QMCS 230: Today in Class Today’s LabToday’s Lab SortingSorting.

Similar presentations


Presentation on theme: "March 2005 1R. Smith - University of St Thomas - Minnesota QMCS 230: Today in Class Today’s LabToday’s Lab SortingSorting."— Presentation transcript:

1 March 2005 1R. Smith - University of St Thomas - Minnesota QMCS 230: Today in Class Today’s LabToday’s Lab SortingSorting

2 March 2005 2R. Smith - University of St Thomas - Minnesota LAB: Selection Sort Create a 15-element arrayCreate a 15-element array Fill it with random numbersFill it with random numbers –Use int, float, or double, as you prefer Print it out so it’s readablePrint it out so it’s readable Sort it using the selection sortSort it using the selection sort Print it out againPrint it out again Write the selection sort as a separate methodWrite the selection sort as a separate method Write the printout procedure as a separate methodWrite the printout procedure as a separate method

3 March 2005 3R. Smith - University of St Thomas - Minnesota Sorting – Selection Sort I know a lot of algorithmsI know a lot of algorithms –I never remember array sorting algorithms –The problem with arrays – everything is in a fixed location Selection SortSelection Sort –Start at one end Find the lowest value in the arrayFind the lowest value in the array Swap it with the first elementSwap it with the first element –Repeat the process for the array minus the first element

4 March 2005 4R. Smith - University of St Thomas - Minnesota Coding the selection sort Two loopsTwo loops Outer loop looks at subsets of the arrayOuter loop looks at subsets of the array Inner loop does “min” on remaining arrayInner loop does “min” on remaining array JavadocJavadoc –Basics: p. 77-78 –@param tag: p. 259 –@return tag: p. 266-7

5 March 2005 5R. Smith - University of St Thomas - Minnesota That’s it. Questions?Questions? Creative Commons License This work is licensed under the Creative Commons Attribution-Share Alike 3.0 United States License. To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/3.0/us/ or send a letter to Creative Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA.


Download ppt "March 2005 1R. Smith - University of St Thomas - Minnesota QMCS 230: Today in Class Today’s LabToday’s Lab SortingSorting."

Similar presentations


Ads by Google