Search the courses, subjects, tracks, games and features, or jump straight to a page.
Learn it your way
A short class with Sarah and her students. The other ways are under More.
Sign up free to listen. Transcripts are free to read.
Today we’re defining a recurrence relation for counting bit strings. Can anyone tell me what we mean by a recurrence relation?
Isn’t it a way of defining a sequence where each term is defined in terms of previous terms?
Exactly! In our case, we'll focus on counting strings that avoid having '000'. We’ll define functions to help with that.
So, how do we actually begin to count those bad strings?
Good question! First, let's define bad strings. We express that by introducing our notation. Let B(n) represent the number of valid strings of length n without '000'.
To remember B(n), think of B for Bad. Each valid string category will connect back through previous B(n) values.
I see! So, we can calculate the following terms based on established patterns?
Yes, precisely! That's the power of a recurrence relation.
Now that we have our definition of B(n), let's categorize the strings to assist with counting.
What are these categories?
Great! We have three main categories. The first starts with '1'. Can anyone tell me why?
Because if it starts with '1', then the rest must also avoid '000'.
Correct! Similarly, the next category starts with '01', and finally, the last one starts with '00' but ends in '1'.
So, is the logic for these categories linked to the lengths of the remaining strings?
Yes! B(n) relates back to B(n-1), B(n-2), and B(n-3). Remember, if we keep counting back, we build a complete equation.
So, the more categories we identify, the more accurate our recurrence will be?
Exactly, and these will feed fully into our next findings!
Now, let's combine our findings into one equation. Can anyone summarize the initial parts?
We have that B(n) = B(n-1) + B(n-2) + B(n-3).
Yes! This relation allows us to explore various string lengths recursively.
When do we actually count those initial conditions?
Good catch! Initial conditions are crucial. We'll set B(1) = 2, B(2) = 4, and B(3) = 7.
So we're saying that for a string of length 1, only '0' and '1' count?
Exactly! Understanding how those conditions lead us gains clarity in our equations moving forward.
Strings that avoid specific undesirable patterns.
Expresses current terms in the sequence based on previous terms.
Distinct classifications pertaining to valid string sequences.
Foundational values necessary to start the sequence.
Bad strings count as we define, start with bits that align!
Imagine weary travelers journeying through lands of numbers. They wish to avoid regions marked by '000' to find safe paths of lengths connecting back to B.
Remember B for Bad Counting! Count backwards through categories to build your B!
B for Bad, B(n) follows: B(n)=B(n-1)+B(n-2)+B(n-3) for bounds.
Term
What does B(n) represent?
Click to flip
Term
What are the initial conditions for bad strings?
Click to flip
This section explores the concept of recurrence relations in the context of counting bad strings that do not contain the substring '000'.
The section delves into recurrence equations to count bit strings of a certain length that avoid specific undesirable patterns. It introduces different categories of bad strings, formulates their recurrence relations, and establishes initial conditions necessary for solving these relationships.
In this section, we explore how to identify and formulate recurrence relations for counting 'bad' strings of a certain length that do not include the substring "000". We start by defining a sequence and its categories based on possible patterns.
Key Functions and Definitions: Let S(n) denote the number of strings of length n that contain the substring "000" to formulate its complement, B(n), denoting the number of strings of length n that do not contain "000". The relationship is defined as:
S(n) = 2^n - B(n).
Categorization of Bad Strings: The bad strings can be divided into three distinct categories:
Formulating Recurrence Relation: We derive:
B(n) = B(n-1) + B(n-2) + B(n-3)
This clearly shows that the number of strings that do not contain "000" relates back to prior counts like a Fibonacci sequence.
Establishing Initial Conditions: Critical values for the recurrence relation to be solvable are:
*B(1) = 2 (strings: '0', '1')*
*B(2) = 4 (strings: '00', '01', '10', '11')*
*B(3) = 7 (strings: '000' is omitted)* Understanding these categories and recurrence relations assists in dynamically calculating non-bad strings.