Implement these three functions in C++ in the code below
selectionSort: sort the provided range using selection sort
reverseRange: reverse the range
printRange: print the range
Do not modify the test code in each function. You can look at that code for some
ideas for implementing the methods.
Note: This is an exercise on iterators, so use their basic functionality
(increment, decrement, dereference, compare) to implement the functions
yourself. Do not call standard library functions to do loops on the given
ranges for you. Also, note that selectionSort is to operate in place, without
making a copy of the data, while for reverseRange you can make use of the data
copy it makes (though you still have to reverse the original range).
#include <algorithm> |
#include <iostream> |
#include <vector> |
template <class Iter> |
void selectionSort(Iter begin,
Iter end) { |
/*******Your code here********/ |
/*****************************/ |
/***Test code: do not modify***/ |
typedef typename
std::iterator_traits<Iter>::value_type value_type; |
Get Free Quote!
351 Experts Online