[CSI] A Couple of Questions

Mikhail Nesterenko mikhail at cs.kent.edu
Mon Dec 12 17:16:05 EST 2016


> 
> I have just one question about the final example exam: for the fourth
> question where you use an iterator to insert an element into the vector and
> remove, could you initialize your iterator ip to v.begin() and use that to
> insert the element with v.insert(ip, 55)?

Assuming you have a vector:

    vector<int> v={1,2,3,4};

You could do this:

    vector<int>::iterator ip=v.begin()+2;
    v.insert(ip, 55);

Or this:

    v.insert(v.begin()+2, 55);

After the execution of either code fragment, the vector will look like
this:

   {1,2,55,3,4}

That is, 55 is inserted in the second position while the rest of the
elements are moved "to the right".

> Also, will recursion and namespaces still be on the exam? I may need to
> review a little if they are.

they are not on the exam this semester since we studied them in CSIA. 
The list of exam topics is here:

  http://www.cs.kent.edu/~mikhail/classes/csi/finalExamTopics.txt

Thanks,
--
Mikhail


More information about the cs13001 mailing list