We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
I think we can further simplify the above boolean function (^ is for XOR):
(((A B) ^ (A + B)) (A ^ B)) =
apply A ^ B = (A'B) + (A B')
( ((A B)' (A + B)) + ((A B) (A + B)')) (A ^ B)) =
apply DeMorgan law (X+Y+...)'=X'Y'Z'... and (XYZ...)'=X'+Y'+...
( ((A' + B') (A + B)) + ((A B) (A' B'))) (A ^ B)) =
apply Distributive Law X(Y+Z) = XY + XZ
(A'A + A'B + AB' + BB' + AA' + BB') (A ^ B) =
apply X+X=X, XX=X
(A'B + AB') (A ^ B) =
(A ^ B) (A ^ B) = A ^ B = A xor B
So we get the same result by just using a simple A XOR B. Is the above simplifacation correct? Can anyone confirm that?
I agree that the entire logical operation can be simplified down to A XOR B because:
1. if you expand A ^ B you get exactly (A & B) ^ (A | B)
2. Idempotent laws states that C & C = C
3. so to save calculation time we can reduce the operation
down to finding the max of what A ^ B is.
I came to the same result.
When there are only 2 inputs A and B, you can also build a truth table to show that (((A & B) ^ (A | B)) & (A ^ B)) = A ^ B ;)
The truth table for the expression given in the question will be same as that of the XOR logic.
It's good to know the math but it's not neccessary here. :)
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Join us
Create a HackerRank account
Be part of a 26 million-strong community of developers
Please signup or login in order to view this challenge
AND xor OR
You are viewing a single comment's thread. Return to all comments →
I think we can further simplify the above boolean function (^ is for XOR):
So we get the same result by just using a simple A XOR B. Is the above simplifacation correct? Can anyone confirm that?
I agree that the entire logical operation can be simplified down to A XOR B because:
Simplify proof
Substitute (A ^ B)
(((A & B) ^ (A | B)) & (A ^ B)) = (((A & B) ^ (A | B)) & ((A & B) ^ (A | B)))
((A & B) ^ (A | B)) & ((A & B) ^ (A | B)) = (A & B) ^ (A | B)
And (A & B) ^ (A | B) = A ^ B --- first equation
Therefore
(((A & B) ^ (A | B)) & (A ^ B)) = A ^ B
in the base case there minimum and next menimum is 2 and 3 and itxor is 1 so how it is correct;
yes u r right
YES IT IS :)
I came to the same result. When there are only 2 inputs A and B, you can also build a truth table to show that (((A & B) ^ (A | B)) & (A ^ B)) = A ^ B ;)
Or since they are all bitwise operations, just figure it out for 4 cases. If you look at the first part:
So you do an equivalent of xoring a number and 'and' that with xoring the number.
Yep I agree. Did the same :)
you can draw de morgan diagrams and things will be trivial - no need to recall formulas or laws
The truth table for the expression given in the question will be same as that of the XOR logic. It's good to know the math but it's not neccessary here. :)