ITPEC IP April 2023 Question 5

There is a program that displays text in accordance with the specifications below. When the original text described below is displayed, in what point size does the program display the underlined character string? Here, the first character of the original text is displayed in 10 points.

[Specifications]

The characters between <B> and </B> are displayed one point larger than the preceding character.

The characters between <S> and </S> are displayed one point smaller than the preceding character.

Each of <B> </B> and <S> </S> must be used as a pair, and both of them can be nested with each other.

[Original text]

The system administrator promotes and implements <B>department-level<B> or

<S>group-level</S> computerization</B> from a user’s <S>standpoint</S>.</B>

Explanation

11 points — the underlined text sits inside the outer B only, one point above the 10-point start.

Track the size as each tag opens and closes (each change is relative to the text before it):

  • •start: 10
  • •first <B>: 11 (department-level)
  • •second <B>, nested: 12 (or)
  • •<S>: 11 (group-level); </S> returns to 12 (computerization)
  • •</B> closes the nested B: back to 11
  • •the underlined from a user’s: 11
  • •then <S>standpoint</S> is 10, and the last </B> closes the outer B

Answer (b)

Why not others:

  • •(a) 10 — the starting size, which returns only after the final </B>; the underlined text is still inside the first <B>
  • •(c) 12 — the size inside both B tags; the </B> after computerization has already closed the nested one
  • •(d) 13 — would need three enlargements in force at once; at the underlined text only one B is open

Key rule: With nested tags, a closing tag restores the size in force before its opening tag, so count only the tags still open at the target text.

Algorithm and Programming · AI-written, may contain errors

This question comes from an official ITPEC past paper. ITPEC Practice is an independent study tool and is not affiliated with ITPEC. See the official IP past-paper collection or Report an issue.