COMP 1005 Lecture 9: Lecture 9
Document Summary
Understand some algorithms on manipulating arrays and lists. An array is a data structure that has elements of the same data type. You must import what is called an array module to define arrays. Arrays loop through all their elements using an index and they can apply many operations such as search, delete, insert, print, sort, etc. Arrays are stored on consecutive locations in memory. There are four steps to finding the maximum element in an array: Loop the rest of the elements leaving a[0] from a[1] to a[6] Compare every time with the new max. if [i] > max (i is greater than max), then max = a[i] (i representing whatever the value was that turned out to be the max). Lecture 9 page 1 representing whatever the value was that turned out to be the max). Passing an array as a parameter to a function.