Description
This lab focuses on a sample implementation of a simple collection using an array for physical storage. After completing this lab you should
- Understand the array manipulation required to implement a simple collection.
- Understand how to accomplish the array resizing necessary to guarantee that only O(N) memory is required for a collection of N elements.
(This document is available outside of Canvas here.)
Set-up
- Open the
COMP2210/labs
directory on your Engineering H: drive. (If you didn’t complete the previous lab where you created this directory structure, do so now.) - Create the
lab07
directory. - Download the zip file associated with this lab, store it in the
COMP2210/labs/lab07
directory, and unzip the file. - Open jGRASP to the
lab07
directory.
ArrayBag
The ArrayBag
directory contains an array-based implementation of the Bag
interface as discussed in lecture. The XML file is a jGRASP Canvas file – layout specification and other settings for pre-configured visualizations of the ArrayBagClient
class.
- Open
ArrayBagClient
in jGRASP and compile it. - Click on the Run in Canvas button in the toolbar.
- Using the debugger controls, single-step over each statement in
ArrayBagClient
. Use the provided Canvas to make sure you understand each part of the code. - Re-run the code, stepping into methods, and creating your own Canvas as needed to make sure that you understand the
ArrayBag
implementation.