Write a recursive procedure to compute the number of strings from $\{A, C, T, G\}$ of length $n$ that do not have $2$ consecutive $A$’s.
2026-04-03 12:50:59.1775220659
Recursion for strings.
68 Views Asked by Bumbble Comm https://math.techqa.club/user/bumbble-comm/detail At
1
There are 1 best solutions below
Related Questions in INDUCTION
- Show that the sequence is bounded below 3
- Fake induction, can't find flaw, every graph with zero edges is connected
- Prove that any truth function $f$ can be represented by a formula $φ$ in cnf by negating a formula in dnf
- Prove $\sum^{n}_{i=1}\binom{n}{i}i=n2^{n-1}$ using binomial and induction
- Induction proof of Fibonacci numbers
- The Martian Monetary System
- How to format a proof by induction
- $x+\frac{1}{x}$ is an integer
- Help with induction proof please! For an integer $n, 3$ divides $n^3-n$
- Proving $\sum_{k=1}^n kk!=(n+1)!−1$
Related Questions in RECURSION
- Solving discrete recursion equations with min in the equation
- Recognizing recursion relation of series that is solutions of $y'' + y' + x^2 y = 0$ around $x_0 = 0$.
- Ackermann Function for $(2,n)$
- Primitive recursive functions of bounded sum
- Ackermann Function for $f(2,n)$ as compared to $f(5,1)$
- Determinant of Block Tridiagonal Matrix
- In how many ways can the basketball be passed between four people so that the ball comes back to $A$ after seven passes? (Use recursion)
- Finding a recursive relation from a differential equation.
- A recursive divisor function
- Are these numbers different from each other?
Trending Questions
- Induction on the number of equations
- How to convince a math teacher of this simple and obvious fact?
- Find $E[XY|Y+Z=1 ]$
- Refuting the Anti-Cantor Cranks
- What are imaginary numbers?
- Determine the adjoint of $\tilde Q(x)$ for $\tilde Q(x)u:=(Qu)(x)$ where $Q:U→L^2(Ω,ℝ^d$ is a Hilbert-Schmidt operator and $U$ is a Hilbert space
- Why does this innovative method of subtraction from a third grader always work?
- How do we know that the number $1$ is not equal to the number $-1$?
- What are the Implications of having VΩ as a model for a theory?
- Defining a Galois Field based on primitive element versus polynomial?
- Can't find the relationship between two columns of numbers. Please Help
- Is computer science a branch of mathematics?
- Is there a bijection of $\mathbb{R}^n$ with itself such that the forward map is connected but the inverse is not?
- Identification of a quadrilateral as a trapezoid, rectangle, or square
- Generator of inertia group in function field extension
Popular # Hahtags
second-order-logic
numerical-methods
puzzle
logic
probability
number-theory
winding-number
real-analysis
integration
calculus
complex-analysis
sequences-and-series
proof-writing
set-theory
functions
homotopy-theory
elementary-number-theory
ordinary-differential-equations
circles
derivatives
game-theory
definite-integrals
elementary-set-theory
limits
multivariable-calculus
geometry
algebraic-number-theory
proof-verification
partial-derivative
algebra-precalculus
Popular Questions
- What is the integral of 1/x?
- How many squares actually ARE in this picture? Is this a trick question with no right answer?
- Is a matrix multiplied with its transpose something special?
- What is the difference between independent and mutually exclusive events?
- Visually stunning math concepts which are easy to explain
- taylor series of $\ln(1+x)$?
- How to tell if a set of vectors spans a space?
- Calculus question taking derivative to find horizontal tangent line
- How to determine if a function is one-to-one?
- Determine if vectors are linearly independent
- What does it mean to have a determinant equal to zero?
- Is this Batman equation for real?
- How to find perpendicular vector to another vector?
- How to find mean and median from histogram
- How many sides does a circle have?
Let
$f(n)$ be length $n$ string starting with $A$ with NO consecutive $A$.
$g(n)$ be length $n$ string not starting with $A$ with NO consecutive $A$.
Then what you want is $h(n)=f(n)+g(n)$ because that counts all strings of length $n$ with no consecutive $A$.
We have $f(n)=g(n-1)$ because for any string in $f(n)$ which has to start with an $A$, the second letter must not be an $A$ and hence the substring starting from the second letter is a member in $g(n-1)$.
We also have $g(n)=3f(n-1)+3g(n-1)$ because the first letter of g(n) is not an $A$ so the substring starting from the second letter can be from either $f(n-1)$ or from $g(n-1)$. We have three choices for the first letter of $g(n)$ so hence the formula.
From this we now $g(n)=3g(n-1)+3g(n-2)$ by sub $f(n-1)=g(n-2)$ into the second equation.
Then from $g(n-1)=3g(n-2)+3g(n-3)$ we sub in $f(n)=g(n-1),f(n-1)=g(n-2),f(n-2)=g(n-3)$ and get $f(n)=3f(n-1)+3f(n-2)$ as well.
Now adding the two equations up, we get $(f(n)+g(n))=3(f(n-1)+g(n-1))+3(f(n-2)+g(n-2))$ hence $h(n)=3h(n-1)+3h(n-2)$ as well.
We have $h(1)=4$ and $h(2)=15$ for initial condition.