A DFA (Deterministic Finite Automaton) is a theoretical machine where: Each input symbol leads to exactly one next state   No ε-transitions (empty moves) are allowed    Every state must have transitions for all input symbols   It is deterministic and predictable Formal Definition A DFA is a 5-tuple: D = (Q, Σ, δ, q₀, F) Where: […] The post A DFA Examples with two states accepts binary strings containing an even number of 1s, switching states every time it reads appeared first on TechBullion.A DFA (Deterministic Finite Automaton) is a theoretical machine where: Each input symbol leads to exactly one next state   No ε-transitions (empty moves) are allowed    Every state must have transitions for all input symbols   It is deterministic and predictable Formal Definition A DFA is a 5-tuple: D = (Q, Σ, δ, q₀, F) Where: […] The post A DFA Examples with two states accepts binary strings containing an even number of 1s, switching states every time it reads appeared first on TechBullion.

A DFA Examples with two states accepts binary strings containing an even number of 1s, switching states every time it reads

A DFA (Deterministic Finite Automaton) is a theoretical machine where:

  • Each input symbol leads to exactly one next state  
  • No ε-transitions (empty moves) are allowed   
  • Every state must have transitions for all input symbols  
  • It is deterministic and predictable

Formal Definition

A DFA is a 5-tuple:
D = (Q, Σ, δ, q₀, F)
Where:

  • Q → set of states 
  • Σ → input alphabet 
  • δ → transition function
  • q₀ → start state  
  • F → final/accepting states

Let discuss major examples of DFA

DFA Example 1: DFA for Strings Ending with 01

This is one of the most common DFA examples.

Language:

All binary strings that end with 01.

Idea:

To accept the string, the last two bits must be 0 → 1.

States Description

  • q0: Starting state
  • q1: Last input was 0
  • q2: Last two inputs were 01 (Final state)

Transition Table

State01
q0q1q0
q1q1q2
q2q1q0

Final State: q2

This DFA accepts: 01, 101, 1001, 0001, etc.

DFA Example 2: DFA for Strings Containing Even Number of 1s

Language:

All strings with even number of 1s.

Idea:

Count the number of 1s modulo 2.

States

  • q0 → even number of 1s (Final state)
  • q1 → odd number of 1s

Transition Table

State01
q0q0q1
q1q1q0

Final State: q0

This DFA accepts strings like:
ε, 0, 00, 11, 1010, 1100, 1001, etc.

DFA Example 3: DFA for Strings With No Two Consecutive 1s

Language:

All binary strings where 11 does not appear.

States

  • q0 → no 1 seen or last is 0
  • q1 → last input was 1
  • qd → dead state (11 is found)

Transition Table

State01
q0q0q1
q1q0qd
qdqdqd

Final States: q0, q1

This DFA accepts strings like:
0, 1, 10, 101, 1010, 01010, etc.

DFA Example 4: DFA for Strings Over {0,1} Divisible by 3 (Binary to Decimal Mod 3)

This is a very popular DFA in exams.

Idea:

Treat input as a binary number and track remainder mod 3.

States

  • q0 → remainder 0
  • q1 → remainder 1
  • q2 → remainder 2

Transition Rule

For each bit b:
new_state = (old_state * 2 + b) mod 3

Transition Table

State01
q0q0q1
q1q2q0
q2q1q2

Final State: q0

Examples accepted:
0, 11 (3), 110 (6), 1001 (9), 1100 (12), etc.

DFA Example 5: DFA for Strings Starting with 1

Language:

All binary strings that start with 1.

States

  • q0 → start state
  • q1 → first symbol was 1 (final)
  • qd → dead state

Transition Table

State01
q0qdq1
q1q1q1
qdqdqd

Final State: q1

Examples accepted:
1, 10, 101, 1000, 111, etc. 

Conclusion

Deterministic Finite Automata (DFA) play a major role in theoretical computer science and real-world computing. The examples above cover the most commonly used DFA patterns — including strings ending with specific patterns, counting characters, avoiding patterns, and number divisibility.

This DFA is frequently used in theory-of-computation exams because it is simple, intuitive, and perfectly illustrates how deterministic finite automata track specific patterns within input strings. The DFA has two states: q₀, which represents that the number of 1s read so far is even, and q₁, which represents that the number is odd. The machine starts in q₀, since before reading any input, the count of 1s is zero, which is even. Whenever the DFA reads a 0, it remains in the same state, because zeros do not affect whether the number of 1s is even or odd. However, each time it reads a 1, it flips to the other state, effectively toggling between even and odd. The accepting state is q₀, meaning the input is accepted only if it ends with an even number of 1s. This DFA is popular because it clearly demonstrates state-based memory and parity checking.

Comments
Market Opportunity
DAR Open Network Logo
DAR Open Network Price(D)
$0.01352
$0.01352$0.01352
0.00%
USD
DAR Open Network (D) Live Price Chart
Disclaimer: The articles reposted on this site are sourced from public platforms and are provided for informational purposes only. They do not necessarily reflect the views of MEXC. All rights remain with the original authors. If you believe any content infringes on third-party rights, please contact service@support.mexc.com for removal. MEXC makes no guarantees regarding the accuracy, completeness, or timeliness of the content and is not responsible for any actions taken based on the information provided. The content does not constitute financial, legal, or other professional advice, nor should it be considered a recommendation or endorsement by MEXC.

You May Also Like

Shocking OpenVPP Partnership Claim Draws Urgent Scrutiny

Shocking OpenVPP Partnership Claim Draws Urgent Scrutiny

The post Shocking OpenVPP Partnership Claim Draws Urgent Scrutiny appeared on BitcoinEthereumNews.com. The cryptocurrency world is buzzing with a recent controversy surrounding a bold OpenVPP partnership claim. This week, OpenVPP (OVPP) announced what it presented as a significant collaboration with the U.S. government in the innovative field of energy tokenization. However, this claim quickly drew the sharp eye of on-chain analyst ZachXBT, who highlighted a swift and official rebuttal that has sent ripples through the digital asset community. What Sparked the OpenVPP Partnership Claim Controversy? The core of the issue revolves around OpenVPP’s assertion of a U.S. government partnership. This kind of collaboration would typically be a monumental endorsement for any private cryptocurrency project, especially given the current regulatory climate. Such a partnership could signify a new era of mainstream adoption and legitimacy for energy tokenization initiatives. OpenVPP initially claimed cooperation with the U.S. government. This alleged partnership was said to be in the domain of energy tokenization. The announcement generated considerable interest and discussion online. ZachXBT, known for his diligent on-chain investigations, was quick to flag the development. He brought attention to the fact that U.S. Securities and Exchange Commission (SEC) Commissioner Hester Peirce had directly addressed the OpenVPP partnership claim. Her response, delivered within hours, was unequivocal and starkly contradicted OpenVPP’s narrative. How Did Regulatory Authorities Respond to the OpenVPP Partnership Claim? Commissioner Hester Peirce’s statement was a crucial turning point in this unfolding story. She clearly stated that the SEC, as an agency, does not engage in partnerships with private cryptocurrency projects. This response effectively dismantled the credibility of OpenVPP’s initial announcement regarding their supposed government collaboration. Peirce’s swift clarification underscores a fundamental principle of regulatory bodies: maintaining impartiality and avoiding endorsements of private entities. Her statement serves as a vital reminder to the crypto community about the official stance of government agencies concerning private ventures. Moreover, ZachXBT’s analysis…
Share
BitcoinEthereumNews2025/09/18 02:13
OpenVPP accused of falsely advertising cooperation with the US government; SEC commissioner clarifies no involvement

OpenVPP accused of falsely advertising cooperation with the US government; SEC commissioner clarifies no involvement

PANews reported on September 17th that on-chain sleuth ZachXBT tweeted that OpenVPP ( $OVPP ) announced this week that it was collaborating with the US government to advance energy tokenization. SEC Commissioner Hester Peirce subsequently responded, stating that the company does not collaborate with or endorse any private crypto projects. The OpenVPP team subsequently hid the response. Several crypto influencers have participated in promoting the project, and the accounts involved have been questioned as typical influencer accounts.
Share
PANews2025/09/17 23:58
Vitalik Buterin’s Minor Token Sales Underscore Ethereum’s Portfolio Dominance

Vitalik Buterin’s Minor Token Sales Underscore Ethereum’s Portfolio Dominance

The post Vitalik Buterin’s Minor Token Sales Underscore Ethereum’s Portfolio Dominance appeared on BitcoinEthereumNews.com. Vitalik Buterin recently sold small
Share
BitcoinEthereumNews2025/12/21 05:14