Skip to content

GATE CS 2022 Q41 — Combinatorics: Counting, Recurrence Relations, Generating Functions

Explain with AI

Consider the following recurrence:

f(1)=1;f(2n)=2f(n)–1,  for  n≥1;f(2n+1)=2f(n)+1,  for  n≥1.\begin{array}{} f(1) & = & 1; \\ f(2n) & = & 2f(n) – 1, & \; \text{for}\; n \geq 1; \\ f(2n+1) & = & 2f(n) + 1, & \; \text{for}\; n \geq 1. \end{array}

Then, which of the following statements is/are TRUE?\text{TRUE}?

Select all correct options
View worked solution

Answer: A;B;C

The given recurrence relation is the classic Josephus recurrence:

f(1)=1f(2n)=2f(n)−1,for n≥1f(2n+1)=2f(n)+1,for n≥1\begin{aligned} f(1) &= 1 \\ f(2n) &= 2f(n) - 1, \quad \text{for } n \geq 1 \\ f(2n+1) &= 2f(n) + 1, \quad \text{for } n \geq 1 \end{aligned}

Any positive integer NN can be uniquely written in the form N=2m+lN = 2^m + l, where m≥0m \geq 0 and 0≤l<2m0 \leq l < 2^m. The closed-form solution for this recurrence is:

f(2m+l)=2l+1f(2^m + l) = 2l + 1

Let us evaluate each option using this closed-form expression:

  • Option A: For f(2n−1)f(2^n - 1), we can write 2n−1=2n−1+(2n−1−1)2^n - 1 = 2^{n-1} + (2^{n-1} - 1). Here, m=n−1m = n-1 and l=2n−1−1l = 2^{n-1} - 1.
    Applying the formula: f(2n−1)=2(2n−1−1)+1=2n−2+1=2n−1f(2^n - 1) = 2(2^{n-1} - 1) + 1 = 2^n - 2 + 1 = 2^n - 1 Thus, Option A is TRUE.
  • Option B: For f(2n)f(2^n), we can write 2n=2n+02^n = 2^n + 0. Here, m=nm = n and l=0l = 0.
    Applying the formula: f(2n)=2(0)+1=1f(2^n) = 2(0) + 1 = 1 Thus, Option B is TRUE.
  • Option C: For f(5⋅2n)f(5 \cdot 2^n), we can write 5⋅2n=2n+2+2n5 \cdot 2^n = 2^{n+2} + 2^n. Here, m=n+2m = n+2 and l=2nl = 2^n (since 2n<2n+22^n < 2^{n+2}).
    Applying the formula: f(5⋅2n)=2(2n)+1=2n+1+1f(5 \cdot 2^n) = 2(2^n) + 1 = 2^{n+1} + 1 Thus, Option C is TRUE.
  • Option D: For f(2n+1)f(2^n + 1), we can write 2n+1=2n+12^n + 1 = 2^n + 1. Here, m=nm = n and l=1l = 1.
    Applying the formula: f(2n+1)=2(1)+1=3f(2^n + 1) = 2(1) + 1 = 3 This is not equal to 2n+12^n + 1 for n>1n > 1. Thus, Option D is FALSE.

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

Published
Report a correction
Keep exploringMore Combinatorics: Counting, Recurrence Relations, Generating Functions questions