Thursday, March 12, 2009

Stack of bits, what will remain?

You have a stack A of 256 bits, 13 are set to 0 and 243 are set to 1. In addition you have an additional stack B of 128 bits all of them set to 1. Until A is empty, you extract two bits from the top of the stack A:
  • if the two extracted bits are different, then you discard the the bit set to 1 and push back the bit set to 0 into the stack A ;
  • if the two extracted bits are equal, then you discard both of them and push into the stack A the a bit extracted by B;
What will be the last bit in the stack A?

No comments:

Post a Comment