Discussion
Consider the following expression: \(x[i] = (p + r) * -s[i] + u/w\). The following sequence shows the list of triples representing the given expression, with entries missing for triples (1), (3), and (6).
| (0) | + | p | r |
| (1) | |||
| (2) | uminus | (1) | |
| (3) | |||
| (4) | / | u | w |
| (5) | + | (3) | (4) |
| (6) | |||
| (7) | = | (6) | (5) |
Which one of the following options fills in the missing entries CORRECTLY?
Answer: A
The missing triples are (1) =[] s i, (3) * (0) (2), (6) []= x i.
Triple (2) applies uminus to the result of (1), and the expression negates \(s[i]\), so (1) must fetch the array element: =[] s i (an indexed read). The product \((p + r) * -s[i]\) multiplies the results of (0) and (2), so (3) is * (0) (2), and (5) then adds \(u/w\) from (4).
The target \(x[i]\) is an indexed location, so (6) is []= x i (an indexed write), and (7) assigns the value from (5) to it.
Options with - in (3) subtract where the expression multiplies, and options with []= in (1) write to s instead of reading it. Putting (5) in triple (6) is wrong because the index of x is i; the value (5) is supplied by triple (7).
Post your comment
Please log in or register to post a comment.
Examination Categories
- SSC Exams
- Banking Exams
- Teaching Exams
- Civil Services Exams
- Railways Exams
- Engineering Recruitment Exams
- Defence Exams
- State Government Exams
- Police Exams
- Insurance Exams
- Nursing Exams
- Other Government Exams
- NRA CET
- PG Entrance Exams
- Campus Placement
- MBA Entrance Exams
- CUET and UG Entrance
- Judiciary Exams
- Regulatory Body Exams
- Software Development