Random Practice Questions on Languages
A stream of freshly drawn questions on languages: compute operations on small sets, decide membership, count words, find a shortest word, and judge claims, with instant checking, hints and step-by-step solutions.
Last updated:
Practice until the operations feel automatic
Every press of “New question” draws a fresh question at random from a set of templates, so you can practise as long as you like.
Choose a level, answer, and the tool checks your answer at once.
A language here is a set of words, and the questions use the operations of Words: Inductive Definitions and Operations and Languages: Operations and Equalities:
union, intersection, difference, symmetric difference, concatenation, reverse, the square and the prefix, suffix and subword sets , and .
Some questions use the languages that the automaton workbench knows (for example “words that end with ”), and some are about DNA sequences or file names.
How the answers are checked
When the answer is a set of words, the tool compares the set you typed with the correct set exactly, over all the words and not only a few samples, and lists the words that are missing from your answer and the words that should not be there.
The shortest-word and counting questions are also checked exactly, and not on the basis of a few sample words.
You can type a set with or without braces, write as ε or eps, and list the words in any order.
The question generator needs JavaScript. Use the written questions below on paper instead.
Add ?seed=123 to the page address to get a specific first question again, for example to discuss it in class. The score and the streak are kept only until you leave the page.
Questions on paper
Question 1. Let and . Compute and say how many words it has.
Hint 1
Write the four products: every word of glued to every word of .
Hint 2
A set lists every word once, even when two pairs give it. Look for two equal products.
Answer
, , , . So , three words: the product appears twice.
Question 2. Is the word in the language , where is “words with an even number of ‘s” and is “words that end with ”?
Hint
Check the two conditions separately: , and (the complement means “not in ”).
Answer
has two ‘s, so it is in . It ends with , so it is in and therefore not in .
The intersection needs both, so the answer is no.
Question 3. How many words of length over contain no two equal letters next to each other?
Hint
After the first letter every letter is forced: it must differ from the previous one.
Answer
The first letter has choices and each of the next three letters has exactly , so there are words:
and .
Back to the glossary.