Upcoming SlideShare
×

# Turing machine

2,798 views

Published on

This presentation provide an example to explain the idea of Turing Machine with two ways infinite tape (BALANCED PARENTHESES EXAMPLE).

Published in: Technology
3 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
Your message goes here
• Be the first to comment

Views
Total views
2,798
On SlideShare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
122
0
Likes
3
Embeds 0
No embeds

No notes for slide

### Turing machine

1. 1. … ε ε a0 a1 … an ε ε … RD Input Tape Head Finite Control qi
2. 2.  Create a Turing Machine that takes as input a string consists of different parentheses ( ), [ ] or { } and ensure if that string is balanced – open parentheses are balanced with closed parentheses – and correct – the smaller one does not include the bigger –. Examples: {[[(()())]()]} Accepted (balanced and correct) [(())(){()()}] Rejected (balanced but wrong) {[()}}{[(())]} Rejected (correct but unbalanced) {()([])}[(()]] Rejected (unbalanced and wrong)
3. 3. Q = { Start , Find1 , Find2 , Find3 , End , Rejected , Accepted }States Description :Start : initial state, that begin to find first symbol ), ] or } then check it with X, Y or Z respectively.Find1 : moving left to find matched symbol (, then check it with X and return to Start state.Find2 : moving left to find matched symbol [, then check it with Y and return to Start state.Find3 : moving left to find matched symbol {, then check it with Z and return to Start state.End : the string is finished, thus moving left to ensure that all symbols are checked.Rejected : there are unchecked (unbalanced) symbols or the string is wrong, therefore string is rejected.Accepted : all symbols are checked (balanced) and the string is correct, therefore string is accepted.
4. 4. Γ ={(,),[,],{,},X,Y,Z,ε} (Tape Alphabet)Σ ={(,),[,],{,}} (Input Alphabet)F = { Accepted } (Finite States)Initial State: StartBlank Symbol: ε
5. 5. δ(q , γ) ( ) [ ] { } X Y Z ε Start Start Find1 Start Find2 Start Find3 Start Start Start End→),],} (,R X,L [,R Y,L {,R Z,L X,R Y,R Z,R ε,L Rejected Rejected Rejected Rejected Rejected Find1 Start Find1 ( X,R - [,L - {,L - X,L Y,L Z,L ε ,R (wrong) (wrong) (wrong) (wrong) (unbalanced) Rejected Rejected Rejected Rejected Find2 - Start Find2 Find2 [ (,L Y,R - {,L - X,L Y,L Z,L ε ,R (unbalanced) (wrong) (wrong) (unbalanced) Rejected Rejected Rejected Find3 Start Find3 Find3 Find3 { (,L - [,L - Z,R - X,L Y,L Z,L ε,R (unbalanced) (unbalanced) (unbalanced) Accepted End Rejected Rejected Rejected End End End ε,R (,L - [,L - {,L - ε (unbalanced) (unbalanced) (unbalanced) X,L Y,L Z,L (correct) (balanced)Rejected Stop - - - - - - - - - -Accepted Stop - - - - - - - - - -
6. 6. X/X,L Find 1 Y/Y,L [/Y,R ε/ε,R Find Accept End ε/ε,L Start (/(,L {/{,L Z/Z,L ε/ε,L Reject 2 ]/Y,L Y/Y,L Find 3X/Y,DX : Scanned SymbolY : Written Symbol [/[,LD : Move Direction
7. 7. A. The string: {[()]} … ε { [ ( ) ] } ε … Start
8. 8. A. The string: {[()]} … ε { [ ( ) ] } ε … Start
9. 9. A. The string: {[()]} … ε { [ ( ) ] } ε … Start
10. 10. A. The string: {[()]} … ε { [ ( ) ] } ε … Start
11. 11. A. The string: {[()]} … ε { [ ( X ] } ε … Find1
12. 12. A. The string: {[()]} … ε { [ X X ] } ε … Start
13. 13. A. The string: {[()]} … ε { [ X X ] } ε … Start
14. 14. A. The string: {[()]} … ε { [ X X Y } ε … Find2
15. 15. A. The string: {[()]} … ε { [ X X Y } ε … Find2
16. 16. A. The string: {[()]} … ε { [ X X Y } ε … Find2
17. 17. A. The string: {[()]} … ε { Y X X Y } ε … Start
18. 18. A. The string: {[()]} … ε { Y X X Y } ε … Start
19. 19. A. The string: {[()]} … ε { Y X X Y } ε … Start
20. 20. A. The string: {[()]} … ε { Y X X Y } ε … Start
21. 21. A. The string: {[()]} … ε { Y X X Y Z ε … Find3
22. 22. A. The string: {[()]} … ε { Y X X Y Z ε … Find3
23. 23. A. The string: {[()]} … ε { Y X X Y Z ε … Find3
24. 24. A. The string: {[()]} … ε { Y X X Y Z ε … Find3
25. 25. A. The string: {[()]} … ε { Y X X Y Z ε … Find3
26. 26. A. The string: {[()]} … ε Z Y X X Y Z ε … Start
27. 27. A. The string: {[()]} … ε Z Y X X Y Z ε … Start
28. 28. A. The string: {[()]} … ε Z Y X X Y Z ε … Start
29. 29. A. The string: {[()]} … ε Z Y X X Y Z ε … Start
30. 30. A. The string: {[()]} … ε Z Y X X Y Z ε … Start
31. 31. A. The string: {[()]} … ε Z Y X X Y Z ε … Start
32. 32. A. The string: {[()]} … ε Z Y X X Y Z ε … End
33. 33. A. The string: {[()]} … ε Z Y X X Y Z ε … End
34. 34. A. The string: {[()]} … ε Z Y X X Y Z ε … End
35. 35. A. The string: {[()]} … ε Z Y X X Y Z ε … End
36. 36. A. The string: {[()]} … ε Z Y X X Y Z ε … End
37. 37. A. The string: {[()]} … ε Z Y X X Y Z ε … End
38. 38. A. The string: {[()]} … ε Z Y X X Y Z ε … End
39. 39. A. The string: {[()]} … ε Z Y X X Y Z ε … Accepted
40. 40. B. The string: [{()}] … ε [ { ( ) } ] ε … Start
41. 41. B. The string: [{()}] … ε [ { ( ) } ] ε … Start
42. 42. B. The string: [{()}] … ε [ { ( ) } ] ε … Start
43. 43. B. The string: [{()}] … ε [ { ( ) } ] ε … Start
44. 44. B. The string: [{()}] … ε [ { ( X } ] ε … Find1
45. 45. B. The string: [{()}] … ε [ { X X } ] ε … Start
46. 46. B. The string: [{()}] … ε [ { X X } ] ε … Start
47. 47. B. The string: [{()}] … ε [ { X X Z ] ε … Find3
48. 48. B. The string: [{()}] … ε [ { X X Z ] ε … Find3
49. 49. B. The string: [{()}] … ε [ { X X Z ] ε … Find3
50. 50. B. The string: [{()}] … ε [ Z X X Z ] ε … Start
51. 51. B. The string: [{()}] … ε [ Z X X Z ] ε … Start
52. 52. B. The string: [{()}] … ε [ Z X X Z ] ε … Start
53. 53. B. The string: [{()}] … ε [ Z X X Z ] ε … Start
54. 54. B. The string: [{()}] … ε [ Z X X Z Y ε … Find2
55. 55. B. The string: [{()}] … ε [ Z X X Z Y ε … Rejected (wrong)
56. 56. C. The string: {[[()] … ε { [ [ ( ) ] ε … Start
57. 57. C. The string: {[[()] … ε { [ [ ( ) ] ε … Start
58. 58. C. The string: {[[()] … ε { [ [ ( ) ] ε … Start
59. 59. C. The string: {[[()] … ε { [ [ ( ) ] ε … Start
60. 60. C. The string: {[[()] … ε { [ [ ( ) ] ε … Start
61. 61. C. The string: {[[()] … ε { [ [ ( X ] ε … Find1
62. 62. C. The string: {[[()] … ε { [ [ X X ] ε … Start
63. 63. C. The string: {[[()] … ε { [ [ X X ] ε … Start
64. 64. C. The string: {[[()] … ε { [ [ X X Y ε … Find2
65. 65. C. The string: {[[()] … ε { [ [ X X Y ε … Find2
66. 66. C. The string: {[[()] … ε { [ [ X X Y ε … Find2
67. 67. C. The string: {[[()] … ε { [ Y X X Y ε … Start
68. 68. C. The string: {[[()] … ε { [ Y X X Y ε … Start
69. 69. C. The string: {[[()] … ε { [ Y X X Y ε … Start
70. 70. C. The string: {[[()] … ε { [ Y X X Y ε … Start
71. 71. C. The string: {[[()] … ε { [ Y X X Y ε … End
72. 72. C. The string: {[[()] … ε { [ Y X X Y ε … End
73. 73. C. The string: {[[()] … ε { [ Y X X Y ε … End
74. 74. C. The string: {[[()] … ε { [ Y X X Y ε … End
75. 75. C. The string: {[[()] … ε { [ Y X X Y ε … End
76. 76. C. The string: {[[()] … ε { [ Y X X Y ε … Rejected (unbalanced)