Skip to content
CourseBook Data Structures
Size
Font
Theme
Warmth
  1. Syllabus
  2. Schedule
  3. Instruction
  4. Logistics
  5. Exams
  6. Homework
  7. How to Study
  8. Demos
  9. Read
  10. The Dynamic Array
    1. What is a Data Structure?
    2. The Array Data Structure
    3. Arrays Have a Fixed Size
    4. Dynamic Arrays
    5. What is Abstraction?
    6. Inside the Dynamic Array
    7. Adding Elements
    8. Growing the Array
    9. Why Study Data Structures?
    10. Classes and Objects
    11. Encapsulation and Information Hiding
    12. What is an Algorithm?
    13. Selection Sort
    14. Where Algorithms Live
    15. Selection Sort with Helper Methods
    16. Removing Elements
    17. A Shared indexOf
    18. The Remove Contract
    19. Structures and Algorithms Together
  11. Generics
    1. Why Generics?
    2. Why Not Just Store Object?
    3. A Generic DynamicArray
    4. The Array Problem
    5. Using It
    6. The Trouble with Primitives
    7. Comparing Elements: equals vs ==
    8. Defining Equality for Student
    9. Ordering Elements: Comparable
    10. Making Student Comparable
    11. A Generic ArrayUtils
    12. Sorting, Generically
    13. Custom Orderings: Comparator
    14. Sorting with a Comparator
    15. Overloading remove: by Index or by Value
    16. The DynamicArray<Integer> Trap
  12. Review
  13. The Dynamic Array
    1. Data Structures and Arrays
    2. Abstraction
    3. Dynamic Array Operations
    4. Search and Removal
    5. Dynamic Array Trace
    6. Algorithms and Selection Sort
  14. Generics
    1. Why Generics, and How to Declare One
    2. Defining Equality
    3. Natural Ordering with Comparable
    4. Generic Sorting with Bounded Type Parameters
    5. External Ordering with Comparator
    6. Overloading remove and the Integer Trap
  15. Practice
  16. The Dynamic Array
    1. Problem: Build a Bag
    2. Solution: Fields and Constructor
    3. Solution: Adding a Ball
    4. Solution: Growing the Bag
    5. Solution: Drawing a Ball at Random
  17. Generics
    1. Problem: Make a Card Orderable
    2. Solution: Value Equality
    3. Solution: A Natural Order
    4. Solution: A Second Order
    5. Problem: A Generic max
    6. Solution: Max by Natural Order
    7. Solution: Max by a Comparator

Review Overview

These questions cover the chapter’s material. Try each one on your own before opening the sample answer. Compare your answer to the sample. If they line up, move on. If they do not, or the sample answer is not clear, it may help to revisit the chapter notes.

  1. Why Generics, and How to Declare One
  2. Defining Equality
  3. Natural Ordering with Comparable
  4. Generic Sorting with Bounded Type Parameters
  5. External Ordering with Comparator
  6. Overloading remove and the Integer Trap
PreviousAlgorithms and Selection Sort NextWhy Generics, and How to Declare One