سوال ۴۷ کنکور ارشد مهندسی کامپیوتر ۱۴۰۴
زبان کدامیک از عبارتهای منظم زیر، با بقیه فرق دارد؟
پاسخ صحیح: گزینهٔ B —
Work over the alphabet and find the language each expression denotes.
Option 1 — . An optional leading , then a concatenation of the blocks and . Each block starts with , and inside the is immediately followed by the next block (which starts with ) or by the end. The optional leading is followed by a block that starts with (or by ). Hence no two consecutive s ever appear, and every such string is generated. So has no substring .
Option 3 — . The mirror construction: blocks and (every is followed by a ), plus an optional trailing . Again exactly the strings with no , so .
Option 4 — . The block is "one-or-more s, then a single ", so every is preceded by a ; the leading is optional and is followed by a block starting with ; the trailing adds only s. No can appear, and all no- strings are produced, so .
Option 2 — . Now both body blocks, and , have length and start with . Therefore the body produces only even-length strings, with the empty string as the sole short case; its shortest non-empty word has length . With at most one optional leading , this expression cannot generate the single-symbol string :
Indeed also misses strings such as and . Three of the four expressions denote the "no two consecutive s" language, while option 2 denotes a strictly different (smaller) language.
Exam trick: When asked which regex is the odd one out, hunt for a tiny witness string. The blocks are all length- and force even-length bodies, so the length- word instantly separates option 2 from the others.