سوال ۵۲ کنکور ارشد مهندسی کامپیوتر ۱۴۰۰
سه زبان با تعاریف زیر مفروضند. کدام گزاره صحیح است؟
پاسخ صحیح: گزینهٔ C — مستقل از متن قطعی و مستقل از متن غیرقطعی است.
Each string has the shape : a prefix over followed by a block of copies of a third symbol . Since , any machine can detect exactly where ends and the -block begins.
— not even context-free. The constraint is , i.e. (number of 's) (number of 's) (number of 's). Intersect with the regular language :
the canonical non-CF language. CFLs are closed under intersection with a regular language, so if were context-free then would be too — contradiction. Hence is not context-free (so certainly not deterministic CF).
— deterministic context-free. Here , i.e. the number of trailing 's equals the length of . A DPDA pushes one marker for every symbol of (deterministic: are clearly distinct from ), and on the first switches to pop mode, popping one marker per and accepting iff the stack empties exactly when the input ends. No guessing is needed, so is a deterministic CFL.
— context-free but nondeterministic. where
Each of and is a single matched-count language, so each is a DCFL, and their union is context-free. But while reading the machine cannot tell whether the upcoming -count will be matched against the number of 's (condition ) or against the full length (condition ) — these require pushing different amounts, so it must guess. The union of two DCFLs of this form is not deterministic. Thus is context-free but nondeterministic.
Checking the options.
| Option | Claim | Verdict |
|---|---|---|
| 1 | both deterministic CF | ✗ ( is nondeterministic) |
| 2 | is nondeterministic CF | ✗ ( is not CF at all) |
| 3 | deterministic, nondeterministic | ✓ |
| 4 | all three are CF | ✗ ( is not CF) |
So the correct choice is option 3, matching the official key.
Exam trick: Two equal-count constraints that are interleaved () collapse to under intersection with → not CF. A single count match ( #o, or #a #o) is a DCFL. An OR of two different single-count matches forces a guess → CF but not deterministic.