Skip to content

Latest commit

 

History

History
37 lines (22 loc) · 1.69 KB

datastructures.md

File metadata and controls

37 lines (22 loc) · 1.69 KB

#Data Structures

###Resources

###Exercises

Complete these exercises in DataStructures.java. Please use the Cat.java class to complete these exercises.

####1. Cool Cats Pt. II

  1. Create an ArrayList of 5 Cats.
  2. Use a loop to print the contents of each object in the ArrayList.

####2. Most Frequent Element

Write a method called mostFrequentElement that takes an ArrayList of Integers and finds the most frequently occurring element in the ArrayList. At the end print the element and its number of occurrences. If there is more than one such element, any one of them may be printed.

Bonus Challenge

What needs to be changed to make this work on an array of Strings?

####3. Pod HashMap

  1. Create a HashMap that maps the names of all the Access Coders in your Pod to their age.
  2. Use a loop to print each key-value pair of the HashMap.

####4. canRentACar

Write a method called canRentACar that takes the Pod HashMap as a parameter and returns whether or not the Pod can rent a car. If one or more studetns is over 25, it should return true. If no one in the Pod is over 25, it should return false.