Lab 10 ©2012 Felleisen, Proulx, et. al.

10  Loops; Sorting


In the first part of the lab you will learn how to convert recursive loops to imperative (mutating) loops using either the Java while statement or the Java for statement to implement the imperative loops.

In the second part we will look at how we can leverage the direct access to the items within the data set to implement a new kind of sorting algorithm.

For this lab download the files in The folder contains the following files:

Create a new Project Lab10 and import into it all files from the zip file. Import the tester.jar and colors.jar.

10.1  Converting Recursive Loops into Imperative while Loops

The goal of this part of the lab is to make sure you know how to implement a traversal over data within an ArrayList using Java while and for loops. Make sure you understand the role of each part of the loop method definition: BASE VALUE, CONTINUATION-PREDICATE, CURRENT, ADVANCE, UPDATE, and know how to construct both the while loop and the for loop.

Last modified: Monday, March 19th, 2012 4:53:30pm