If you are not allowed to run the code you should step through each line, one by one, and think what will be the content of the arrays and the vector after each step.
Note that a runtime error is an error that happens when the program runs. This means you will not have to worry about trivial syntax errors (such as a missing semicolon or a misspelled function name) because that would give you an error at compile time, not at runtime.
Thank you Peter87,
If I run the code I will get the b answer, but at line 10 and 11 is sorted just a part of arrays and then we apply set_diference to the whole arrays, is not correct. My question is, in a school test what is the right answer a or b?
You're right. The arrays should be sorted before using set_difference. I think this is considered a runtime error, even though it might not give you an error message, because there is no guarantee that it will work. It's simply undefined behaviour.
The C++ standard doesn't specify the exact implementation. The cplusplus.com reference page probably means it's equivalent to that piece of of code under the assumption that the preconditions are fulfilled (i.e. the ranges [first1,last1) and [first2,last2) are sorted).
Nevertheless, the given equivalent code gives a defined outcome in this specific case.
My understanding of the purpose of such equivalent code is to not go into the intricacies of any particular compiler implementation, but to allow the functioning of the algorithm to be understood in terms which might be considered as in effect pseudocode for that algorithm.