

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Information about a university computer science homework assignment focused on implementing vector data structure with bag and findmin interfaces. It includes instructions, due date, and study questions related to vector data structures and java programming concepts. The assignment requires students to modify the vector class and write answers to given questions.
Typology: Assignments
1 / 2
This page cannot be seen from the preview
Don't miss anything!


Homework #3: Vectors (30 pts) Due date: Friday, April 18, 2003 (5:00 PM)
This assignment is designed to make you think about the Vector data structure. Treat this paper as a specification for your assignment. We will grade you code by providing a class that fully tests the various method that you will implement. Study problems and exercises must be legible and will be graded on cor- rectness.
Written homework:
Vector v = new Vector(); v.setSize(4); v.setElementAt(“A”, 3); v.setElementAt(“B”, 1); v.removeLast(); v.addElementAt(“C”, 2); v.addLast(“D”); v.setSize(6);
E 6.5) To illustrate that the expected execution time for addLast is constant, imagine that we start with an empty vector and perform 25 successive addLast operations. To estimate the execution time for each, assign a value of 1 to those executions that can be performed in constant time and a value equal to the size of the old vector to those executions that require a reallocation. (Note that the book says to use the new size, but we want you to use the old size.) Then sum the values and divide by 25. How large is the resulting average? (Assume that the initial array size is 8) ( 3 pts )
E 6.6) Suppose that instead of doubling the size of the vector when a reallocation occurs, we sim- ply increase the size of the vector by 1. Perform the same analysis as described in the previ- ous question. How large is the resulting average now? ( 3 pts )
In class: a printout of written homework in the file Answers.txt and a printout of your source files VectorBag.java and VectorMin.java.
Via the web: the files VectorBag.java, VectorMin.java, and Answers.txt.