ArraysLearningObjectives

Document Sample
ArraysLearningObjectives Powered By Docstoc
					                      Standard Data Structures - Arrays
                                       Learning Objectives

What is an array?                                   Algorithms to study
                                                       - how to check consecutive elements
What can arrays be used for?                           - average elements in an array
                                                       - swap elements in an array
What type of data can arrays hold?                     - find max/min of the elements in an array
  - primitive data types                                  (introduction of Integer.MAX_VALUE,
  - objects                                               Integer.MIN_VALUE)
                                                       - find the index of the max or min element
What are the limitations of arrays?                    - how to expand an array (make a new one
  - fixed in size                                         that is larger, copy elements over, delete
  - each cell must hold the same type of item             original)
                                                       - how to copy an array
How to declare an array?                               - how to search for an element
  - use an initializer list                               (linear/binary)
  - or instantiate an “empty” array by using           - how to sort an array (selection/insertion)
     the new operator
                                                    Two-dimensional arrays
Arrays can’t really ever be empty                     - what are they used for
   - int arrays are filled with 0 when created        - traverse by going across the rows
   - double arrays with 0.o                           - (0,0) is top left corner
   - boolean arrays filled with false                 - square arrays vs. ragged arrays
   - char arrays filled with space                    - how to calculate # columns
   - object arrays filled with null                   - .length means # of rows

To populate an array, you can:                      Things to stress
   - use an initializer list                           - out of bound errors
   - use brute force                                   - initialize max / min values to be first
   - use a loop                                          element or Integer constants

To print the elements of an array:
   - if you just print the name of the array, you
      will get the memory address
   - you must loop over the elements of the
      array, printing each element as you go

Introduction of the foreach loop
   - aka the enhanced for loop
Limitations:
   - can't check certain elements, must check
      them all
   - can't modify elements
   - no access to index numbers
   - can’t check consecutive elements

Advantages:
   - simpler syntax

				
DOCUMENT INFO
Categories:
Tags:
Stats:
views:4
posted:7/30/2012
language:
pages:1