Computer Science, asked by geethageet91, 1 year ago

A language has 28 different letters in total. Each word in the language is composed of maximum 7 letters. You want to create a data-type to store a word of this language. You decide to store the word as an array of letters. How many bits will you assign to the data-type to be able to store all kinds of words of the language.

Answers

Answered by sungajbhiye051
0

This may be the answer you seek

1 bit -> 2 possible states

2 bits -> 4 possible states

3 bits -> 8 possible states

4 bits -> 16 possible states

5 bits -> 32 possible states

(I hope you see the pattern here)

You need 5 bits to represent all possible letters in the language (28 > 16 & 28 < 32). Since you are told you are storing an array of letters, you will need a total of 5*7 bits = 35 bits to represent all words in the language. (You actually need 29 symbols per array element, not 28, since you need a 'null' symbol to signify shorter than 7 letter words, but that doesn't change the answer.)

Now, in reality no sane person would actually do this in practice on a real computer. They would just store 7 bytes (or possibly 8, for a terminating null character (C-style string) to simplify processing.)

Similar questions