Fall 2016, Siena College

Lecture 09: ArrayList/Vector Implementation
Date: Monday, September 26, 2016

Agenda

• Announcements
• Hoping to have extra office hours again tomorrow afternoon
• Lab 3: Defining Classes continues
• Exam 1 Information
• during lab meeting on Wednesday, October 5
• this exam is 10% of the course grade
• topics covered are up to ArrayList/Vector implementations (not the complexity and asymptotic analysis)
• closed book, closed notes, closed neighbors
• practice exam questions will be out Wednesday, sample solutions will be made available outside my office door on Monday of next week
• optional review time Tuesday evening 10/4, time and place TBA
• Lecture 08 assignment recap
• Implementing and analyzing the Vector class

Due at the start of class, Monday, October 10.

Please submit answers to these questions in Blackboard under "Lecture 09 Assignment" by the start of class. We will discuss these questions at the start of class, so no late submissions can be accepted.

Write the class described in Bailey Problem 3.6, p. 65. (30 points total)

• You may limit your implementation to include the following constructors and public methods. You might want to have some helper methods (like the ensureCapacity method of stucture5.Vector).
• a default constructor that creates a BitVector with slots initially for 10 boolean values (2 points)
• a second constructor that takes a parameter specifying the number of slots (1 point)
• add to the end (3 points)
• add at a given position (2 points)
• contains (2 points)
• get (1 point)
• indexOf (2 points)
• clear (1 point)
• remove (by position) (2 points)
• set (1 point)
• size (1 point)
• toString (2 points).

Use the Vector implementation in the structure package as a guide! Most of your code can and should be very similar.

• Write a main method that thoroughly tests your class and all of its constructors and methods. (5 points)
• Include as part of the comment at the top of your program your response to this question. What are the advantages and disadvantages of using a BitVector as you implemented it as compared to using a Vector or ArrayList that stores boolean values. (5 points)

Please submit only the file BitVector.java.

Examples