CS 240: Algorithms and Data Structures
James Madison University, Fall 2020

Introduction

Your goals for this lab are to introduce two enhancements to the OpenDSA AList class introduced in our textbook:

  1. Enable dynamic resizing so that it is not necessary to specify a maximum capacity when the AList is instantiated.
  2. Implement the Iterable interface, including the remove operation.

Starter Code

Dynamically Arrays

Dynamic arrays use the following algorithm to ensure sufficient capacity when new elements are added:

if the current array is full:
    * Allocate a new array that is twice as large as the current array.
    * Copy all entries from the current array to the new array.
    * Replace the current array with the newly allocated array.

The first stage for this lab is to update the OpenDSA AList class so that it performs these steps every time append or insert is called. Since the same steps are required for both methods, it would be appropriate to create a private helper method.

Iterator

The second stage of the lab involves completing the methods of the unfinished Iterator class declared at the bottom of AList. One complication involves how removing elements using the iterator should impact the current position (curr) of the AList object. The expected behavior is as follows:

If this is unclear, I encourage you to read the provided unit tests to get a better understanding of the required behavior.

Submitting

Submit AList.java through Autolab.