Class 9 - Lists and Arrays, continued Matthew Hashim Click...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
12/4/09 Click to edit Master subtitle style Lists and Arrays, continued Matthew Hashim 9/22/2009 11
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
MGMT 290D 12/4/09 Goals n Use random numbers to vary the behavior of a program n Use an array to store multiple items 22
Background image of page 2
MGMT 290D 12/4/09 The Array Structure n Fixed-size container that can store a group of values ¨ Data items are accessed by position (as in a list) ¨ Values of data items can be changed at run-time ¨ The capacity of an array cannot change at run-time n Two reasons for using an array instead of a list ¨ The array is more memory-efficient than a list ¨ An array is more time-efficient for accessing an item 33
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
MGMT 290D 12/4/09 Array Example 1: The Ants Go Marching n User story: soldier ant sings a song while marching n View the story as a counting problem ¨ The ant song is 10 verses long ¨ Most of the lines are repeated ¨ A for loop can be used to iterate through 10 verses n Managing the differences in lines using parallel arrays ¨ One String array stores the verse-specific numbers
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 12/04/2009 for the course MGMT 290 taught by Professor Staff during the Fall '08 term at Purdue.

Page1 / 13

Class 9 - Lists and Arrays, continued Matthew Hashim Click...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online