Short Programming Questions

Description

Hi, I have attached below the instructions for this assignment so please take a look at that to see what needs to be done for this assignment. Please make sure to follow the instructions/guidelines provided to complete the assignment! This is very important! Let me know if you have any questions or if there’s something that you find confusing about the instructions that you would like me to clear up with you!

Don't use plagiarized sources. Get Your Custom Assignment on
Short Programming Questions
From as Little as $13/Page

Unformatted Attachment Preview

Q2 Policy-based design
1 Within the selection_sort_template.h header file, implement the
selection_sort function. This function should take two iterators
representing a range within an arbitrary container (e.g., vector, array).
Additionally, include an optional functor parameter to allow the
replacement of the default operator< for element comparison. The selection_sort function is designed to sort the elements within the specified range based on the provided optional functor using the selection sort algorithm. You find the details of this algorithm in the PIC10B notes For simplicity, we assume that the first iterator must be positioned before the second iterator in the container For example, the function signature of the selection_sort function can be template void selection_sort(Iterator first, Iterator last,Compare comp = Compare()) 2 Avoid using the -- operation within the selection_sort function since many iterator classes do not support it. 3 The file HW6P1.cpp is given as follows. Please make sure your templated functions are compatible with the code provided here #include #include #include #include #include "selection_sort_template.h" bool compareSquares(int x, int y) { return x * x < y* y; }; auto bySize = [](const std::string& x, const std::string& y) -> bool{ return x.size() < y.size(); }; int main() { std::vector container1 = { 3, 1, 4, -5, 6, 9 }; auto begin1 = std::begin(container1); auto end1 = std::end(container1); selection_sort(begin1, end1); for (auto it = begin1; it != end1; ++it) { std::cout Purchase answer to see full attachment