Skip to content
Official PYQ · 2008

GATE CS 2008 Q79 — Asymptotic Worst Case Time and Space Complexity

Explain with AI

Let xnx_n denote the number of binary strings of length nn that contain no consecutive 00s.

The value of x5x_5 is 

Marks were awarded to all candidates for this question. It is not scored as a normal quiz.

View worked solution

Marks to all

To find the number of binary strings of length nn with no consecutive 00s, we can set up a recurrence relation based on the ending bit of the string:

  • Case 1: The string ends with 1. The remaining n−1n-1 bits can be any valid string of length n−1n-1 with no consecutive 00s. There are xn−1x_{n-1} such strings.
  • Case 2: The string ends with 0. To avoid consecutive 00s, the second-to-last bit must be 1. The remaining n−2n-2 bits can be any valid string of length n−2n-2 with no consecutive 00s. There are xn−2x_{n-2} such strings.

This gives the recurrence relation:

xn=xn−1+xn−2for n≥3x_n = x_{n-1} + x_{n-2} \quad \text{for } n \ge 3

Let's calculate the base cases directly:

  • For n=1n = 1: Valid strings are 0 and 1   ⟹  x1=2\implies x_1 = 2.
  • For n=2n = 2: Valid strings are 01, 10, and 11   ⟹  x2=3\implies x_2 = 3.

Using the recurrence relation, we compute the subsequent terms:

  • x3=x2+x1=3+2=5x_3 = x_2 + x_1 = 3 + 2 = 5
  • x4=x3+x2=5+3=8x_4 = x_3 + x_2 = 5 + 3 = 8
  • x5=x4+x3=8+5=13x_5 = x_4 + x_3 = 8 + 5 = 13

The correct mathematical value for x5x_5 is 13. Since 1313 is not present in the given options (Option D is listed as 16), this question has no correct option, leading to the official answer key being marked as X (Marks to All).

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Asymptotic Worst Case Time and Space Complexity questions