1 1 vote What is the correct answer to this problem? In the key, the answer is given as A but I'm getting C. Please tell me why it is so. Thanks. Compiler Design compiler-design syntax-directed-translation ace-test-series + – Lakshay Kakkar 1.8k views answer comment Share Follow Print See all 7 Comments 7 7 Comments reply Show 4 previous comments joshi_nitish commented Nov 20, 2017 reply Follow flag yes, C is correct. 0 0 replyShare srestha commented Nov 20, 2017 reply Follow flag @ joshi_nitish In option A) it is told A.evenx=!(A1.evenx) So, how do u determine x is even here? x could be even as well as odd rt? 0 0 replyShare Aakash_ commented Nov 30, 2018 reply Follow flag yes Answer is C, ACE has given wrong answer. 0 0 replyShare Please log in or register to add a comment.
Best answer –1 –1 vote https://gateoverflow.in/171923/ace-test-series This Question is already asked and It's ans should be C Ashwin Kulkarni answered Nov 20, 2017 • selected Jun 14, 2018 by Lakshay Kakkar Ashwin Kulkarni comment Share Follow See all 2 Comments 2 2 Comments reply Lakshay Kakkar commented Nov 20, 2017 reply Follow flag No explanation is provided at all there. Concluding something without any proper reasoning is not the right way to prepare. 1 1 replyShare Ashwin Kulkarni commented Nov 20, 2017 i edited by Ashwin Kulkarni Nov 20, 2017 reply Follow flag In that link that Q is asked for just confirmation. and here explanation was not discussed. Anyway here's is explanation : evenx is a Boolean variable which keeps track if number of x are even or odd If number of x's in A or A1 are even then A.evenx = true or A1.evenx = true respectively if x's are odd in A or A1 then A.evenx or A1.evenx = false respectively A.n and A1.n counts number of x's in A and A1 respectively. In option A) If A1.evenx = true (i.e. there are even number of x's in A1.) then obviously A.evenx = odd and vice versa. (Because A.evenx will be A1.evenx + 1 : how? because A = xA1y hence to the string A1, x and y are concatenated. and that's why number of x's in A will be 1 more than number of x's in A1.) In option B) With the help of above explanation to find number of x's in A we need to calculate (A.n % 2). (A.n % 2) ==0 then it will return "true" and that value will be assigned to A.evenx. Hope you'll get it :) And hence both A and B are correct, Hence answer is C 0 0 replyShare Please log in or register to add a comment.
–1 –1 vote Yes Ans should be option C. Ashwin Kulkarni answered Nov 19, 2017 Ashwin Kulkarni comment Share Follow 0 reply Please log in or register to add a comment.