1 votes 1 votes 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 asked Nov 20, 2017 • retagged Jun 22, 2022 by Lakshman Bhaiya Lakshay Kakkar 850 views answer comment Share Follow See all 7 Comments See all 7 7 Comments reply Show 4 previous comments joshi_nitish commented Nov 20, 2017 reply Follow Share yes, C is correct. 0 votes 0 votes srestha commented Nov 20, 2017 reply Follow Share @ 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 votes 0 votes Aakash_ commented Nov 30, 2018 reply Follow Share yes Answer is C, ACE has given wrong answer. 0 votes 0 votes Please log in or register to add a comment.
Best answer –1 votes –1 votes 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 See all 2 2 Comments reply Lakshay Kakkar commented Nov 20, 2017 reply Follow Share No explanation is provided at all there. Concluding something without any proper reasoning is not the right way to prepare. 1 votes 1 votes Ashwin Kulkarni commented Nov 20, 2017 i edited by Ashwin Kulkarni Nov 20, 2017 reply Follow Share 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 votes 0 votes Please log in or register to add a comment.
–1 votes –1 votes Yes Ans should be option C. Ashwin Kulkarni answered Nov 19, 2017 Ashwin Kulkarni comment Share Follow See all 0 reply Please log in or register to add a comment.