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

2025/11/26 15:19

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
시장 기회
DAR Open Network 로고
DAR Open Network 가격(D)
$0.01325
$0.01325$0.01325
-1.99%
USD
DAR Open Network (D) 실시간 가격 차트
면책 조항: 본 사이트에 재게시된 글들은 공개 플랫폼에서 가져온 것으로 정보 제공 목적으로만 제공됩니다. 이는 반드시 MEXC의 견해를 반영하는 것은 아닙니다. 모든 권리는 원저자에게 있습니다. 제3자의 권리를 침해하는 콘텐츠가 있다고 판단될 경우, service@support.mexc.com으로 연락하여 삭제 요청을 해주시기 바랍니다. MEXC는 콘텐츠의 정확성, 완전성 또는 시의적절성에 대해 어떠한 보증도 하지 않으며, 제공된 정보에 기반하여 취해진 어떠한 조치에 대해서도 책임을 지지 않습니다. 본 콘텐츠는 금융, 법률 또는 기타 전문적인 조언을 구성하지 않으며, MEXC의 추천이나 보증으로 간주되어서는 안 됩니다.

추천 콘텐츠

NY Fed President Highlights CPI Distortion After Shutdown

NY Fed President Highlights CPI Distortion After Shutdown

NY Fed President John Williams discusses the November CPI distortion due to a six-week government shutdown impacting data collection.
공유하기
CoinLive2025/12/21 07:54
Why Bitcoin Outperforms Gold as the Ultimate Long-Term Store of Value, Says Analyst

Why Bitcoin Outperforms Gold as the Ultimate Long-Term Store of Value, Says Analyst

Bitcoin’s Long-Term Outperformance Over Gold, Says Expert Bitcoin is poised to outperform gold over the long term, according to market analyst and Bitcoin advocate
공유하기
Crypto Breaking News2025/12/21 08:01
Big Bull Cathie Wood Makes Flash Statements: “Gold, Compared to Bitcoin…”

Big Bull Cathie Wood Makes Flash Statements: “Gold, Compared to Bitcoin…”

The post Big Bull Cathie Wood Makes Flash Statements: “Gold, Compared to Bitcoin…” appeared on BitcoinEthereumNews.com. ARK Invest CEO and Chief Investment Officer (CIO) Cathie Wood made remarkable statements on many topics, from global markets to US inflation, from the cryptocurrency industry to initial public offerings (IPOs), during the Bloomberg ETF IQ program on Bloomberg TV. Answering questions from Katie Greifeld, Eric Balchunas, and Scarlet Fu, Wood painted an optimistic picture for the markets, particularly defending Bitcoin’s superiority over gold. The most resonant part of Wood’s speech was his statement of faith in Bitcoin: “Bitcoin is undoubtedly better than gold.” Wood noted that investors are currently implementing a “barbell strategy” involving stocks (in anticipation of low interest rates and economic recovery) and gold/crypto assets (as a hedge), adding that cryptocurrencies have performed well over time despite being more volatile. Wood noted that ARK Invest has “very good exposure” to the cryptocurrency cycle, arguing that stablecoins (Tether and Circle, 90% of the market) provide a significant gateway to the decentralized finance (DeFi) ecosystem. He also explained why his funds favor Digital Asset Trusts (DATs) like Bitmine and Soulmate over Ether exchange-traded funds (ETFs). The primary reason, Wood explained, is that generating returns through staking is a crucial part of the Ethereum story, something ETFs currently don’t allow. He noted that this strategy gives ARK exposure to the “big three” of Bitcoin, Ethereum, and Solana. *This is not investment advice. Follow our Telegram and Twitter account now for exclusive news, analytics and on-chain data! Source: https://en.bitcoinsistemi.com/big-bull-cathie-wood-makes-flash-statements-gold-compared-to-bitcoin/
공유하기
BitcoinEthereumNews2025/10/02 15:47