Microsoft Interview Question
Software Engineer / DevelopersWe have set of data in the buffer. Each chracters might Single byte or double byte. That mean mixed of ASCII and double byte chracters. We need to implement backspace algorithm. Each character first bit will give us the information about double or ASCII. That means if the first bit is 0 - chracter is AsCII and 1 means double byte
I think this is very simple.
Parse 1 byte (char) from the buffer. Now AND this char with 1000000 and see if this value is non zero. If non zero then it means that the 1st bit of our char is 1, this means that that char is double byte so increment 2 spaces in your buffer or if the AND value is 0 then it means that the 1st bit in our char is 0, so increment 1 space in our buffer.
Do I make sense ???
Assumption: our machine on which we are operating is a Big endian style. if it is a little endian machine then we need to AND the above algorithm with 00000001.
Let me know if I missed any point.
dint understand your question. Can you elaborate a little more if u can ?
- Rasmus April 07, 2011