1 / 35

TM accepting strings with equal number of 0’s and 1’s

TM accepting strings with equal number of 0’s and 1’s. Thamer Al sulaiman. TM accepting strings with equal number of 0’s and 1’s. The T uring machine accepts strings such as: 001110, 1011. The Turing Machine rejects strings such as: 010, 11100 and so on. . Algorithm.

bill
Download Presentation

TM accepting strings with equal number of 0’s and 1’s

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. TM accepting strings with equal number of 0’s and 1’s Thamer Al sulaiman

  2. TM accepting strings with equal number of 0’s and 1’s • The Turing machine accepts strings such as: 001110, 1011. • The Turing Machine rejects strings such as: 010, 11100 and so on.

  3. Algorithm A possible algorithm to solve this problem is: • For each symbol: 0 (1) read from input tape, search for a matching 1 (0), and replace both symbols with another symbol (to ignore matched symbols in subsequent steps). • If the respective symbol is not found – the end of the string reached without matching symbol (which means the string contains an unequal number of 0s and 1s), then we reject. • If all 0s and 1s are matched, then accept.

  4. Δ/Δ,R q A Δ/Δ,R • - q is the initial state, • R is the rejection state, • F is the acceptance state. 0/x,R 1/x,R x/x,R 0/0,R Δ/Δ,R Δ/Δ,R C R B 1/1,R 1/x,L 0/x,L 0/0,L D 1/1,L 1/x,R 0/x,R x/x,L Δ/Δ,R E x/x,R Δ/Δ,R F

  5. Δ/Δ,R q A Δ/Δ,R 0/x,R 1/x,R x/x,R 0/0,R Δ/Δ,R Δ/Δ,R C R B 1/1,R 1/x,L 0/x,L 0/0,L D 1/1,L 1/x,R 0/x,R x/x,L Input string: 001 Δ/Δ,R E x/x,R q Δ001 Δ/Δ,R F

  6. Δ/Δ,R q A Δ/Δ,R 0/x,R 1/x,R x/x,R 0/0,R Δ/Δ,R Δ/Δ,R C R B 1/1,R 1/x,L 0/x,L 0/0,L D 1/1,L 1/x,R 0/x,R x/x,L Input string: 001 Δ/Δ,R E x/x,R q Δ001 ⊢ ΔA001 Δ/Δ,R F

  7. Δ/Δ,R q A Δ/Δ,R 0/x,R 1/x,R x/x,R 0/0,R Δ/Δ,R Δ/Δ,R C R B 1/1,R 1/x,L 0/x,L 0/0,L D 1/1,L 1/x,R 0/x,R x/x,L Input string: 001 Δ/Δ,R E x/x,R q Δ001 ⊢ ΔA001 ⊢ ΔxC01 Δ/Δ,R F

  8. Δ/Δ,R q A Δ/Δ,R 0/x,R 1/x,R x/x,R 0/0,R Δ/Δ,R Δ/Δ,R C R B 1/1,R 1/x,L 0/x,L 0/0,L D 1/1,L 1/x,R 0/x,R x/x,L Input string: 001 Δ/Δ,R E x/x,R q Δ001 ⊢ ΔA001 ⊢ ΔxC01 ⊢ Δx0C1 Δ/Δ,R F

  9. Δ/Δ,R q A Δ/Δ,R 0/x,R 1/x,R x/x,R 0/0,R Δ/Δ,R Δ/Δ,R C R B 1/1,R 1/x,L 0/x,L 0/0,L D 1/1,L 1/x,R 0/x,R x/x,L Input string: 001 Δ/Δ,R E x/x,R q Δ001 ⊢ ΔA001 ⊢ ΔxC01 ⊢ Δx0C1 ⊢ ΔxD0x Δ/Δ,R F

  10. Δ/Δ,R q A Δ/Δ,R 0/x,R 1/x,R x/x,R 0/0,R Δ/Δ,R Δ/Δ,R C R B 1/1,R 1/x,L 0/x,L 0/0,L D 1/1,L 1/x,R 0/x,R x/x,L Input string: 001 Δ/Δ,R E x/x,R q Δ001 ⊢ ΔA001 ⊢ ΔxC01 ⊢ Δx0C1 ⊢ ΔxD0x ⊢ ΔDx0x Δ/Δ,R F

  11. Δ/Δ,R q A Δ/Δ,R 0/x,R 1/x,R x/x,R 0/0,R Δ/Δ,R Δ/Δ,R C R B 1/1,R 1/x,L 0/x,L 0/0,L D 1/1,L 1/x,R 0/x,R x/x,L Input string: 001 Δ/Δ,R E x/x,R q Δ001 ⊢ ΔA001 ⊢ ΔxC01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