Interview Questions

Anyone is having algorithm for Multibyte backspace? ......

Microsoft Interview Questions and Answers


(Continued from previous question...)

102. Anyone is having algorithm for Multibyte backspace? ......

Question:
Anyone is having algorithm for Multibyte backspace? If the previous character is single byte move one character. otherwise need to move 2 bytes.


maybe an answer:


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

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.

(Continued on next question...)

Other Interview Questions