Regular_Expressions_flashcards

1
Q

What is a regular expression?

A

A symbolic way of describing a pattern in a set of strings (a language).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Give an example of a regular expression over {0,1} that matches a string with some 0s, a 1, any bit, and a 0.

A

0*1(0 ∪ 1)0

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the regular expression for: ‘either empty string or even number of 1s followed by a 0’?

A

ε ∪ (11)*0

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What language does the regex (010)* ∪ (00 ∪ 11)* describe?

A

Strings made of repeated 010 blocks or repeated 00/11 blocks.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are the base elements of REG(Σ)?

A

a ∈ Σ, ε, ∅

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are the 3 operations that extend REG(Σ)?

A

Union (α ∪ β), Concatenation (αβ), Kleene star (α*)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the operator precedence in regular expressions?

A

Star > Concatenation > Union

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What does the regular expression ab* ∪ b*a mean?

A

The set of strings of the form abⁿ or bⁿa

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What does (ab(a ∪ b))* represent?

A

All strings made by repeating aba or abb patterns.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the language of (b ∪ aba)?

A

Strings over {a,b} with an even number of a’s.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What does L(a) equal for a regular expression?

A

{a}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What does L(ε) equal?

A

{ε} — the set containing only the empty word.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What does L(∅) equal?

A

The empty language — it contains no strings.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is L(α ∪ β)?

A

The union of L(α) and L(β): L(α) ∪ L(β)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is L(αβ)?

A

The concatenation of L(α) and L(β): L(α)L(β)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is L(α*)?

A

The Kleene star of L(α): all strings formed by zero or more concatenations of elements of L(α)

17
Q

What is the key theorem connecting regular expressions and regular languages?

A

A language is regular if and only if it can be described by a regular expression.

18
Q

How do we prove that every regex defines a regular language?

A

Use induction and closure properties of regular languages.

19
Q

Can every DFA/NFA be converted into a regex?

A

Yes — this proves the other direction of the equivalence.

20
Q

What is the practical method for converting a regex to an NFA?

A

Build sub-NFAs for components and combine using ε-transitions.

21
Q

Why should you simplify regular expressions during NFA construction?

A

To avoid a large and complex NFA from growing out of control.

22
Q

Name three real-world uses of regular expressions.

A

Text search, lexical analysis, pattern validation

23
Q

What are some common tools that use regex?

A

Text editors, search engines, web scrapers, compilers

24
Q

How do regular expressions relate to finite automata?

A

They describe the same class of languages (regular languages).