表1の結果から,次の命令を実行したときに表示されるレコード数は幾つか。
件数表示([性能=1] or [価格=1])
出典 平成27年度 春期 ITパスポート試験 問99
解説
問 99
//
※ Our check while writing this explanation could not fully confirm the published answer; scoring follows IPA's official key.
×Incorrectア
60 is exactly the count of [price=1] in Table 1. The union expressed by or includes not only “people who value price” but also “people who value performance”, so the 25 people who do not value price but do value performance (55-30) are left out. This is a typical mistake of answering with the count of just one of the conditions.
×Incorrectイ
70 is the value you get when you take the wrong row from Table 1. For example, using 45 for [design=1] instead of 60 for [price=1] gives 55+45-30=70, or subtracting the 30 people of the and condition from the total of 100 respondents gives 100-30=70. Neither calculation corresponds to the condition in the question (the or of performance and price), so it is wrong.
○ウ
正解In this set of linked questions, 100 respondents were asked whether they place importance on “performance”, “price” and “design”, recording 1 for yes and 0 for no. The results in Table 1 are: [performance=1] is 55 records, [price=1] is 60 records, and [performance=1] and [price=1] is 30 records. The or in the command being asked about, Count display ([performance=1] or [price=1]), is a logical OR, so it counts the union of “the set of people who value performance” and “the set of people who value price” (people who satisfy at least one of the two conditions). If you simply add 55+60, the 30 people who value both are counted twice. So you use the inclusion-exclusion principle (size of the union = A + B - A∩B), giving 55+60-30=85. Checking with the breakdown: performance only = 55-30=25 people, price only = 60-30=30 people, and both = 30 people, so 25+30+30=85 people, which matches. Therefore the number of records displayed is 85, and the correct answer is ウ.
×Incorrectエ
115 is the value obtained by simply adding 55+60, which counts the 30 people who value both performance and price twice. Moreover, since there are only 100 respondents in total, the number of records can never be 115. This is a representative wrong answer for forgetting to subtract the overlap (the intersection).
ここがポイント
In a search condition, or corresponds to logical OR = the union of sets, and and corresponds to logical AND = the intersection. When you count records, use the inclusion-exclusion principle |A∪B|=|A|+|B|-|A∩B| and always remove the double counting of the part that satisfies both conditions.
The values read from the table are “the count for each condition”, not a breakdown of mutually exclusive groups. The 55 for [performance=1] already includes the 30 people who value both, so the number of people who value only one of them is easier to picture when you find it by subtraction, such as 55-30=25 (drawing a Venn diagram makes it certain).