since it is guaranteed that l points to the start of the character.
Thus I would refer to 'X‘ as the byte l points to. Each number in the
following represents the MSB of the corresponding byte. E.g. 101X -->
the byte preceding X has MSB 1 and the byte preceding that has MSB 0
the byte preceding that has MSB 1. The k-th character refers to the k-
th character to the left of X.

Now let's consider the following situation, where
1X
Since X is the start of a character, thus the preceding byte couldn't
the first byte of the 2-byte character albeit the MSB is 1. Thus we
delete 1 byte preceding X.

For the situation
*******0X
where the preceding byte MSB 0 we want to know if it is the start of a
1-byte character or the second byte of a 2-byte character. Thus we
need to look back further.

For 00X, we delete 1 byte since the 2nd byte has MSB 0, which means it
either the second byte or the 1-byte character, either way, the 1st
byte stands alone.

For 010X, we delete 2. Similar logic.

For 0110X, we delete one.

Continue doing in the similar fashion, we conclude that if the 1st
byte has MSB 0, count the number of 1s between that byte and the first
byte to its left that has MSB 0 or we reach the very first byte of
array. If the number of 1s is even, (including 0), delete 1 character
preceding X and 2 otherwise.

On Feb 15, 12:11 pm, jalaj jaiswal <[email protected]> wrote:
> give an example as what to do .. tha language of the question is not clear
> to me
>
>
>
>
>
>
>
>
>
> On Tue, Feb 15, 2011 at 5:32 PM, bittu <[email protected]> wrote:
> > Given a byte array, in which characters can be 1 byte or 2 bytes long
>
> > For 1-byte characters, the Most significant bit must be 0. For a 2-
> > byte character, the most significant bit of the most significant byte
> > must be one and the most significant bit of the least significant byte
> > is don’t care (X). You are given the index, I of a character in the
> > byte array. Note that I-1 or I+1 can lead you to either a character or
> > the middle of a character. Give a logic (no need of code) to delete
> > the previous character of the one to which I points.
>
> > Please Read The Question Carefully..Mean While I am Also think for
> > Solution
>
> > Thanks & Regards
> > Shashank
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Algorithm Geeks" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to
> > [email protected].
> > For more options, visit this group at
> >http://groups.google.com/group/algogeeks?hl=en.
>
> --
> With Regards,
> *Jalaj Jaiswal* (+919019947895)
> Software developer, Cisco Systems
> B.Tech IIIT ALLAHABAD

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to