Lesson 16 – Algorithms for ArrayList

Big Java 6

When you come in

  1. Connect to the Internet
  2. Log in to Piazza
  3. Start Bluej
  4. Navigate to laughton.com/obrien/sjsu/cs46a/CRT_lessons/ and open this lesson

Questions

Concept: Loop algorithms applied to ArrayLists

When we talked about loops, we looked at several algorithms. They are very useful when working with ArrayLists

Concept: Finding the sum

 

Activity - ArrayList of objects: sum

Record your participation in Piazza clicker question Lesson16 Q1

 

Activity - ArrayList of objects: average

Record your participation in Piazza clicker question Lesson16 Q2

 

Concept: Finding the maximum

Activity - ArrayList of objects: Largest

Record your participation in Piazza clicker question Lesson16 Q3

 

Concept: Finding the first match

  set a boolean flag found to false
  initialize a variable first 
  initialize a loop control variable index to 0
  while there are more elements to look at and !found 
     if this element is a match
        set first to this element
        set found to true
     else
        increment index 

Activity - ArrayList of objects: find first match

Record your participation in Piazza clicker question Lesson16 Q4

 

Activity - ArrayList of objects: count

Record your participation in Piazza clicker question Lesson16 Q5

 

Activity - ArrayList of objects: find all matches

Record your participation in Piazza clicker question Lesson16 Q6