Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2019
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. 1. RE
  2. 1. Find specified set of string in text
  3. 2. A notation to specify a set of strings
  4. 3. AB*A: zero or more occurance of B
  5. 4. wildcard: .
  6. 5. character class [A-Z]
  7. 6. At least 1 A(BC)+DE
  8. 7. exactly k [0-9]{5}-[0-9]{4}
  9. 2. NFAs
  10. 1. Kleene’s algorithm: for any RE there is an DFA and vice versa
  11. 2. Same as for KMP
  12. 1. No backup in text input stream
  13. 2. linear-time guarantee
  14. 3. exponential number of states
  15. 3. Nondeterministic finite state automata (NFA)
  16. 1. Epsilon-transition (not deterministic)
  17. 2. Accept if any sequence of transitions ends in accept state
  18. 3. systematically consider all possible transitions
  19. 3. DFA Simulation
  20. 1. State names: integers from 0 to M
  21. 2. Match-transitions: keep regular rxpression in array re[]
  22. 3. e-transitions: store in a digraph G
  23. 4. Maintain all possible states that NFA could be in and reach to all possible states
  24. 5. Accept if any state reachable is an accept state
  25. 6. Reject otherwise
  26. 7. Digraph reachability: directedDFS from each source, without unmarking vertices
  27. 1. find all possibilities until leaf node
  28. 8. MN worst case, average close to linear
  29. 4. NFA Construction
  30. 1. Closure: single (go back to the previous state), after parenthesis (go back to previous parenthesis)
  31. 2. Or: Add two e-transition edges for each |
  32. 3. Use stack
  33. 4. O(M)
  34. 5. RE Applications
  35. 1. Grep
  36. 2. crossword puzzles
  37. 3. awk
  38. 4. PERL (built on RE)
  39. 5. Harvesting information
  40. 6. Complexity attack: can implement RE do not guarantee performance to attack
  41. 7. SpamAssasin RE
  42. 8. \1 matches subexpression that was matched earier (periodic pattern)
  43. 9. RE is the basis of compiler
  44. 10. Worst-case of Java string.matches (exponential to N) (depending on the implementation details: this is on DFA with backtracking, also in Python re)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement