Some error occured while loading page for you. Please try again.
Sort 8 Discussions, By:
Please Login in order to post a comment
Another incorrect and/or ambiguous question answer. As already stated in past comments, the answer is only correct if all operators are of the same precedence.
So, HackerRank - why aren't these questions reviewed before they are released? Also, why does it take over a year to correct an error?
In this source, p21 for example, there exists a precedence order between the set operators, which means that the operations are not necessarily evaluated from left to right. Did anyone verify the answers marked as correct?
if there are operators of the same precedence in the expression, the operation is performed left to right
(a++ *2 )+ (a-- * 2);
it'll result in 2 differnt answers if performed in opposite directions
For the same precedence, yes. But the question does not specify that. For operations with difference precedence, the expression is not executed from left to right.
I agree, the marked answer is clearly wrong.
This question is not written in clear and precise English. Evaluation is from left to right only after the precedence rules are considered. For more, please see here:
"Precedence is a simple ordering, based on either the importance or sequence. In
relational algebra, the unary operators Π, σ and ρ have the highest precedence.
Next highest is the Cartesian product operator × followed by the join operators
✶, A./ and ./@. The set difference operator − is evaluated next. Finally are the
operators ∪ and ∩. This is the default precedence."
Left to right is the correct answer for this question..
Precedence of the set of operations is basically performed in left to right.
left to rigth
After however many years, this question is still incorrect, in terms of the expected answer. There is nothing stating whether the expression has operators of different precedences, or whether there are any parentheses to be considered.
If the question is not updated to provide more information, then the correct answer should be changed to Depends on the Expression.
I agree with everyone below that this problem & answer are sub-par and likely incorrect.
We probably need to modify / adjust this problem to not be so simplistic in the answer...there is a pretty involved discussion here on stackexchange about set operator precedence and how parentheses are needed to disambiguate the order of operations.... it does not appear to be as simple as left to right:
it similiar to that of bodmas i gues from LR
during execution complier always reads from left to right but in expressions compiler follows BODMAS rule to execute it.
No more comments