

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
A programming assignment from ucla math department's introduction to programming course during the summer 2009 session. Students are required to write a vector library for vector<int> by implementing several functions such as tally, mode, find_first, partial_sum, position_of_min, disagree, subsequence, and reverse_vector. The functions should be implemented in hwk3.cpp, while main.cpp will be provided for testing. Students must adhere to certain guidelines, such as not writing to cout or reading from cin, and ensuring successful program building.
Typology: Assignments
1 / 3
This page cannot be seen from the preview
Don't miss anything!


As a programmer you will spend lots of time working with vectors, thus it is important to feel comfortable manipulating them. In this assignment we will write a small library for vector
int tally(vector
int disagree(vector
Return the index of the first corresponding elements of v1 and v2 that are not equal. If the vectors are equal up to the point where one or both of the vectors runs out, return the smaller of v1.size() and v2.size(). For example:
vector
vector
vector
disagree(v5, v5); // returns 3 disagree(v5, v6); // returns 1 disagree(v5, v7); // returns 1
bool subsequence(vector
Return true if all the elements in v2 appear in v1 in the same order (although maybe not consecutively). Otherwise, return false. For example:
vector
vector
vector
subsequence(big, v8); // returns true subsequence(big, v9); // returns false