Algorithms and OOD (CSC 207 2014F) : Assignments

Assignment 2: An Expandable Array ADT

Due: 10:30 p.m., Sunday, 31 August 2014

Summary: An important aspect of ADT design is choosing which methods one might include in the ADT. We explore that aspect by seeing what other programmers have done.

Purposes: To get you started thinking about ADT design. To provide some resources for early discussions of ADT design. To get you started working on Github. To give you some experience in code reading. To get you started using markdown.

Expected Time: One to two hours.

Collaboration: Each student should turn in his, her, or zir on answers for this assignment. You may, however, discuss the assignment with anyone you like. You may even work side-by-side, discussing things as you go. You must credit any discussions you had with other students.

Submitting: Fill in your answer in the Wiki page at

Warning: So that this assignment is a learning experience for everyone, we will almost certainly spend class time publicly critiquing work.

Preliminaries: Thinking about Arrays

A core aspect of this course is the design and implementation of abstract data types, which specify the organization of information by use within a program.

In the programming that you've done in Scheme and C you've encountered the array ADT (called a “vector” in Scheme). Arrays are collections of values that are indexed by integers between 0 and one less than the length of the array. A difficulty with traditional arrays in C (and vectors in Scheme) is that they are fixed size: Once you've chosen the size of an array, you can't later make it larger or smaller.

In response to this problem, many programmers build libraries in which they can treat arrays as if they were expandable. How? Typically, they keep a reference to the array and, if it's not big enough, they allocate a larger array and copy over the data.

Amazingly, there are many ways that programmers provide this simple expandable array ADT to client code, where client code may simply mean the rest of the program or may mean other programs that use the implementation.

Our primary objective in this assignment (and the planned followup discussion) is to consider the ways in which programmers might design and implement expandable arrays.


Find a project written that includes an implementation of expandable arrays in C. I would prefer that you find it on Github, but you can look elsewhere on the Internet.

Skim through the implementation and then answer the following questions on the Wiki page at

After answering each question, put your initials in brackets after your answer. (If you see an answer that does not differ substantially from what you might write, you are allowed to put the word "ditto" and your initials in brackets after the previous answer.)

  • Please give the name and the URL of the project you've found. Also indicate where we can find the implementation of expandable arrays within that project.
  • Describe one or two operations that client programmers can use to work with these expandable arrays. (The client may be another part of the same program.) Our goal is to get a large list of possible operations (or variants of similar operations) that we can compare and contrast.
  • What did you learn from reading the code?

Once you've answered the three questions, please put acknowledgements at the end of the document.

Important Evaluation Criteria

I will primarily gauge your answers on their thoughtfulness. Did you simply put down the first thing that you found or that came to mind, or did you think a bit about what the code represented?