Question
01. Given that all necessary libraries are included and given the following declarations: vector vec; // code to fill vec with unique integers vector::iterator itr;
01. Given that all necessary libraries are included and given the following declarations: vector vec; // code to fill vec with unique integers vector::iterator itr; int index; write the code to delete a given integer num from vec .
02. Write a template function to fill in a deque with a given vector
03. Write a recursive function that calculates the summation of an array: int location(double a[], int first, int last, double item); /* returns the location of item in a[first], , a[last]. If not found, return 0. */
04. Write a function DiffFromAverage which receives a list lst action: computes the average of the elements outputs the difference between the largest element and the average outputs the difference between the smallest element and the average algorithm: does not contain a loop; instead uses STL library functions
05/a
. . Suppose you are implementing a customized data structure Sta as a wrapper around an STL list. 10 a) Complete the following class declaration (Write only the prototypes and the private data field; definitions will follow the class declaration): template class Sta { public: // eraseElt function to remove the item which is equal to a given value Elt _______________________________________________________ // pop function to return the item at the top of the sta, and also to remove it from the stack ___________________________________________________________ // updateElt function to update a given value to the new value. If there are more than one items of the given value, update all of them to the new value. ____________________________________________________________ // push function to add an item to the sta ____________________________________________________________ private: // list to hold the elements of the sta ____________________________________________________________ }; 6
05/b
i) Write the definition of the pop function and implement it also(as it would appear following the class declaration). Assume there are only push_back, pop_front, front, begin, end, insert and erase functions in list. You must use iterator to implement the function.
ii) Write the definition of the updateElt function and implement it also(as it would appear following the class declaration). Assume there are only push_back, pop_front, front, begin, end, insert and erase functions in list. You must use iterator to implement the function.
iii) Write the definition of the eraseElt function and implement it also(as it would appear following the class declaration). Assume there are only push_back, pop_front, front, begin, end, insert and erase functions in list. You must use iterator to implement the function.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started