Implement the function by scanning the list


Discuss the below:

Q: Implement, according to the instructions in parts (a) and (b), the fnction count(), which takes item as argument and returns the number of times item occurs in a list.

template -------please see attachment for this portion
int count (const list& aList, constT& item);

a) Implement the function by scanning the list and maintaining a count of the number of occurrences of item

b) Implement the function by making repeated calls to seqSearch() until the return iterator is aList.end().

template
list:: iterator seqSearch (list::iterator first, list::iterator last, const T& target)
{
list::iterator iter = first;
while(iter!= last &&(*iter!= target))
iter++
return iter;
}

Solution Preview :

Prepared by a verified Expert
C/C++ Programming: Implement the function by scanning the list
Reference No:- TGS01937444

Now Priced at $20 (50% Discount)

Recommended (92%)

Rated (4.4/5)