A~Z の26種類の文字を表現する文字コードに最小限必要なビット数は幾つか。
平成30年度 春期 ITパスポート試験 問75
This question's explanation and your answers so far.
問 75
Incorrectア
With 4 bits, only 2 to the 4th power = 16 patterns can be represented, which is not enough for 26 characters, so it is incorrect.
- イ
正解 The number of patterns that can be represented with n bits is 2 to the power of n. To assign a different code to each of the 26 characters from A to Z, at least 26 patterns are needed. With 5 bits, 2 to the 5th power = 32 patterns, so all 26 characters can be represented. With 4 bits, there are only 2 to the 4th power = 16 patterns, which does not reach 26. Therefore, the minimum number of bits required is 5 bits, and the correct answer is “イ”.
Incorrectウ
With 6 bits, 2 to the 6th power = 64 patterns can be represented, which satisfies 26 characters, but 5 bits (32 patterns) is already enough, so it is not the minimum and is incorrect.
Incorrectエ
With 7 bits, 2 to the 7th power = 128 patterns satisfies 26 characters, but the smaller 5 bits is already enough, so it is not the minimum and is incorrect.
- The number of kinds of information (patterns) that n bits can represent is 2 to the power of n; to distinguish K kinds, find the smallest n for which 2 to the power of n is greater than or equal to K.
- Since 26 kinds fall between 2 to the 4th power = 16 and 2 to the 5th power = 32, the minimum number of bits satisfying the condition is 5 bits.