CompSci 4Chap 10 Nov 29, 2005Prof. Susan RodgerAnnouncements• We will continue to work with arrays this week.• Assignment 7– Storyboard due – World is due Thursday.Research Study Continued• Your choice whether or not to participate• You will be emailed your id number from Camelia Pearson Eaves (LSRC D230)• I do not know your number or whether you choose to participate• Benefit – Take a survey (test) that may help in preparing you for the final exam.What we will do today• Continue with Chap 10– Sorting arrays• Classwork – practice with arraysArrays in Alice - review• In Alice, array is a data structure to organize objects or information• An array is not visible, it is a way of organizing• But….– Alice has a 3D model to help you “see” the arraySetting elements in array• Objects in an array are called elements• Use “let” to set a position in an array• Using “let”.Accessing elements in an array• Can specify an element at a particular location in the arrayRepeat for all items in the array –in order• Use “loop” – complicated version• Note: index in loop is used in body• What does this do?• What does this do?Swapping two elements in the array at the same time• Swap the objects at positions 0 and 3Shuffle the array• For each item in the array, swap it randomly with another objectSelectionSort the array• Find the position of the shortest object– Swap that object with the object in position 0• Find the position of the next shortest object– Swap that object with the object in position 1• Etc…. Until the array is sorted.Classwork Today• Shuffle Array• Sort
View Full Document