سوال ۴۷ کنکور ارشد مهندسی کامپیوتر ۱۴۰۵
زبانهای و زیر را در نظر بگیرید. کدام مورد درست است؟
پاسخ صحیح: گزینهٔ C — و هر دو زبان حساس به متن هستند.
Both and demand equal counts across three or more distinct symbols, which is exactly the border between context-free and context-sensitive languages.
Neither is context-free. is the textbook language that is not context-free: the CFL pumping lemma fails. For with , the block touches at most two of the three symbol groups, so pumping changes at most two counts and breaks the equality . The identical argument rules out (four equal blocks). So option 4 is wrong.
Both are context-sensitive (type 1). Each is generated by a non-contracting grammar (no rule shortens the string), equivalently recognized by a linear-bounded automaton (LBA) whose tape — linear in the input length — can count and compare the blocks. A classic context-sensitive grammar for is:
- , , ,
(for this derives ). An analogous grammar handles .
Chomsky hierarchy.
Every context-sensitive language is also type 0, so claiming they are "type 0 but not context-sensitive" (option 1) is false; the tightest correct class is context-sensitive. And is context-sensitive exactly like , so option 2 fails too.
Hence both and are context-sensitive — option 3.
Exam trick: is context-free, but requiring three or more blocks with equal exponents (, ) pushes the language out of context-free and squarely into context-sensitive.