Skip to content

平成27年度 春期 ITパスポート試験 問100

This question's explanation and your answers so far.

問100
頻出度★★☆

F社では,新製品を開発するに当たり,100人のモニタを募集して市場調査を行った。モニタには,性能,価格,デザインの三つの項目について,それぞれを重視するかどうかを“はい”又は“いいえ”のいずれかで答えてもらった。 モニタから得られた回答は,図1のレコード形式で回答ファイルに登録した。 レコードの項目“性能”,“価格”,“デザイン”には,それぞれ,質問に対する回答が“はい”の場合には1が,“いいえ”の場合には0が記録されている。 回答ファイルの中から,条件に合致するレコード数を表示するために,次の命令が使用できる。 件数表示(条件) ここで,条件には,and,or及び[ ]を組み合わせた複合条件を指定できる。条件の評価は[ ]の中が優先して評価される。また,[ ]の中にさらに[ ]を記述することもできる。 条件を変えて,命令を実行した結果を表1に示す。 表1 命令を実行した結果

条件件数表示命令の実行結果
性能=155
価格=160
デザイン=145
[性能=1]and[価格=1]30
[価格=1]and[デザイン=1]25

次の手続によって得られる結果と同じ結果が得られる命令の記述はどれか。 〔手続〕 (1) 件数表示(価格=1)を実行し,表示される結果を w とする。 (2) 件数表示([性能=1] and [価格=1])を実行し,表示される結果を x とする。 (3) 件数表示([価格=1] and [デザイン=1])を実行し,表示される結果を y とする。 (4) 件数表示([性能=1] and [価格=1] and [デザイン=1])を実行し,表示される結果を z とする。 (5) w-x-y+z を計算する。

出典 平成27年度 春期 ITパスポート試験 問100
解説

問 100

  • ア

    正解 Let P be the set with Performance=1, K the set with Price=1, and D the set with Design=1. Then w=|K|, x=|P∩K|, y=|K∩D|, and z=|P∩K∩D|. Subtracting x and y from w removes from K the part that belongs to P and the part that belongs to D, but the overlap that belongs to both P and D (P∩K∩D) gets subtracted twice, so z is added back as a correction. The result w-x-y+z = |K|-|K∩P|-|K∩D|+|K∩P∩D| represents the number of records with Price=1 that are neither Performance=1 nor Design=1 — that is, the count of the part of K belonging to neither P nor D. Written as a single command this is Count display ([Performance=0] and [Price=1] and [Design=0]), so ア is correct.

  • Incorrectイ

    In “[Performance=0] or [Price=1] or [Design=0]” all three conditions are joined by or, so a record is counted whenever even one of them holds. A record with Price=0, for instance, is still counted as long as Performance=0, making the set far wider than the “Price=1 and Performance=0 and Design=0” that the procedure asks for. Note also that, by De Morgan's laws, this expression is the negation of the condition in ウ.

  • Incorrectウ

    Every item value here is the exact opposite of ア: the expression counts records with Performance=1, Price=0 and Design=1. The procedure starts from w=|K|, the count of records with Price=1, and no matter what is added or subtracted afterwards the target stays limited to records with Price=1, so it cannot match an expression whose condition requires Price=0.

  • Incorrectエ

    Negating the condition of ア, “[Performance=0] and [Price=1] and [Design=0]”, by De Morgan's laws swaps and with or and flips each condition, giving “[Performance=1] or [Price=0] or [Design=1]”. In other words エ counts the complement of ア, so its count equals the total number of records minus the result of the procedure (w-x-y+z). That is exactly the reverse of what is being asked for, so it does not match.

ここがポイント
  • Inclusion-exclusion principle: subtract |K∩P| and |K∩D| from |K|, then add back |K∩P∩D|, which was subtracted twice, and you obtain |K∩P^c∩D^c|. It is easier to picture with a Venn diagram, erasing from the K region the parts that overlap P and D.
  • De Morgan's laws: negating an entire condition expression swaps and with or and negates each individual condition. Remembering that the negation of [Performance=0] and [Price=1] and [Design=0] is [Performance=1] or [Price=0] or [Design=1] lets you quickly tell apart the and-type and or-type choices, which come in negation pairs.
用語
解答問100ア
Practise this question

Your answers