In the video it is shown by passing parameters as sort(a, a+n) where both the parameters denote start and end position but my doubt was why it was passed as sort(a, a+n) and not as sort(a, n).
Doubt Regarding parameters in built in sort function of STL
sort is inbuilt function and it has function definition that we can’t change
It generally takes two parameters, the first one being the point of the array/vector from where the sorting needs to begin and the second parameter being the length up to which we want the array/vector to get sorted.
you can read this documentation for detail knowledge about sort function
https://www.cplusplus.com/reference/algorithm/sort/
Ya first and last i know but why (a, a+n) and not (a,n)
That’s what I explain
Sort is a inbuilt function
It’s predefined we can’t change its parameters
We have to call it as such
If you call it like sort(a,n)
Then second parameter is integer not address hence give error
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.
Okay Thanks alot for your help