GATE / CS ARCHIVE

GATE CSE 1995 / QUESTION 2.9

String head and tail operations

Compiler Design · Other / Mixed Topics · Full GATE CSE 1995 paper

GATE 1995, Q2.9 2 marks · MCQ
Not in GATE 2027 syllabusReport issue

Other / Mixed Topics

Question 2.9, GATE 1995: For s=acbc, head returns the first character, tail removes it, and concat joins strings. Evaluate concat(head(s),head(tail(tail(s)))).
Tap to enlarge
Your answer
Answer & solution

Answer: C: ab (no official key was published)

Starting with s=acbc, the first tail is cbc and the second is bc. The head of that second tail is b. Separately head(s)=a. Concatenating a and b gives ab. This follows the nesting from the inside outward; taking only one tail would produce c instead. Among ac,bc,ab,cc, this is option C.

Original paper, page 4