Interactive · 7 questions
Definition. An alphabet is any set, most commonly a set of letters or numbers. We usually denote an alphabet by ("s"igma for "s"tring, probably).
Which of the following are alphabets?
Definition. A string is a sequence of elements from an alphabet. We generally denote the empty string by .
Which are the following are strings from
By that definition, is a valid alphabet?
Now let's look at the operations we can perform on strings.
Length. The length of the sequence the string represents. It is denoted by . For example .
Substring. If our string is then the substring starting at and ending at (denoted as ) is the string . This is only well-defined when , but we also define the substring to be empty if .
Concatenation. Take two strings and put them next to each other. For example the concatenation of and is . The concatenation of and is .
Multiple concatenations. For a string and we denote as concatenated with itself times. In particular, .
In the alphabet , let and . Select all that are true.
From the alphabet , is a valid string?
Finally, there is the notion of lexicographical order. First, someone must assign some order on the alphabet . For example, I may order by .
To determine the lexicographical order of two strings and , we sequentially compare , then , etc., until we have some inequality. In particular, if and only if: , or and , or and and , or and , or and and and , etc.
Also denote for all .
Let be ordered by . What is the lexicographical order of and ?
Let be ordered by . What is the lexicographical order of and ?