Let’s say there are 5 elements in array (a is our array) and i want to start sorting from 1st index. Then the arguments i have to pass are (a+1, a+n) or (a+1, a+n-1)???
Please explain it in detail why we using that argument and not the other one.
Soting doubt sorting doubt
sort(a+1,a+n)
first argument is starting address and second argument is ending address
Sorts the elements in the range [first,last) into ascending order
last not included
see the definition of sort function
template <class RandomAccessIterator>
void sort (RandomAccessIterator first, RandomAccessIterator last);
Sorts the elements in the range [first,last) into ascending order.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.