Final answer:
The 'countOutliers' function counts elements in a vector that are outside the range of two integer parameters, adjusting for their order and returning 0 for an empty vector.
Step-by-step explanation:
The countOutliers function is designed to find and count elements within a vector that are outside the range defined by two integer parameters. The function should work regardless of the order of the two integer bounds. If the vector is empty, the function returns 0. This task involves concepts of programming, functions, and iteration over data structures.
To write this function, you would start by ensuring that the lower bound is less than the upper bound, swapping them if necessary. Then, iterate through the vector, incrementing a count for each element that is less than the lower bound or greater than the upper bound. Finally, return the count.
Here's a generic example in pseudocode:
function countOutliers(vector, int1, int2) {
lowerBound = min(int1, int2)
upperBound = max(int1, int2)
count = 0
for each value in vector {
if value < lowerBound or value > upperBound {
count = count + 1
}
}
return count
}