ITM 207 Lecture 9: Sequential and Binary
Document Summary
Heterogeneous collection of items in which individual items are accessed by name: employee can bundle name, age and hourly wage items. Homogeneous collection of items which an individual item is accessed by its position (index) within the collection. As data is being read into an array, a counter is updated so that we always know how many data items were stored: if array is called list we are working with, list[0] to list[length-1] or list[1] list[length] Searching for an element in an array. Consider each element starting from 1st and compare it to what is being looked for. If two values match then item is found: if not, the next element is considered in the array and comparison is repeated. The search is stopped as soon as the item is found or when there are no more array elements left to check. Sorting re-arranges the elements into either ascending or descending order within the array.