I need help creating a single tape deterministic Turing machine for this language
here I am not sure how to determine which strings the TM will accept. How can I make the machine accept strings where a=c? because the b part has elements from both a and c.
Maybe you can try do adapt a machine which accepts palidromes: you read a character to the left. If it belongs to {0,1} you delete it and go to the right (the last character). If the character belongs to {2,3}, you delete it and go back to the left (the first character). Repeat it until you find a character which does not belong to the "a" or "c" side (and check the last character if you were on the left), the remaining characters should belong to the "b" block.
Related
I'm not good with English but hope I can make my question clear.
I have a table with tons of rows, all written in the format 00000 (ex.: 000001, 00002 etc). I need to change all of them by adding a letter in a fixed point of the number (00A000, 00A001 etc), always the same letter, always in the same position. So, either i manage to change the format of the rows to a custom format number-number-letter-number-number-number (which i'm able to do in Excel, but i can't find a way in Access), or I create an update query to add the letter A in that spot. Anyone can help?
I tired to change the format as i said, but can't find a way to add custom format in access. I've tried to use an update query to add the letter after the 3rd character from the RIGHT, but i'ìve written the query wrong
You show one value with 6 digits and other with 5 digits. If that is correct, consider (x represents your field or string): Left(x,2) & "A" & Mid(x,3)
If that is a posting error and all values are same length of 5 digits, consider: Format(x, "00A000").
Could run an UPDATE action to change data in field but it is not necessary as this calculation can be done when needed in query or textbox.
Could change field to a number type instead of storing repetitious characters. Also, Format property could use: 00\A000.
I have been searching on good use-cases and differences between the use of LIKE and = where I faced this problem regarding LIKE.
Since LIKE "_r%" means those with 'r' as their second character, doesn't it hold to assume that "r%_" means those with 'r' as their first character, essentially making it functionally same as "a%".
I am asking this because our lecture slides says the otherwise, and I am not sure whether I am wrong or not. I have also ran this SQL test program (https://www.w3schools.com/sql/trysql.asp?filename=trysql_select_like_underscore) to see it firsthand and this also proves my point.
Have a good day.
No, both r%_ and r% don't actually mean the same thing. The first version r%_ will match any string starting with r, followed by zero or more of any character, followed by any single character. This pattern will match ra and ran, but it will not match single r. The pattern r% on the other hand will match r, since % allows for zero characters following the leading r.
The difference is that a% will match anything that starts with a, including a by itself (% matches zero, one, or multiple characters), while a%_ will match anything that starts with a, but must be followed by at least one other character (_ matches exactly one character).
I am learning basics of SQL through W3School and during understanding basics of wildcards I went through the following query:
--Finds any values that start with "a" and are at least 3 characters in length
WHERE CustomerName LIKE 'a_%_%'
as per the example following query will search the table where CustomerName column start with 'a' and have at least 3 characters in length.
However, I try the following query also:
WHERE CustomerName LIKE 'a__%'
The above query also gives me the exact same result.
I want to know whether there is any difference in both queries? Does the second query produce a different output in some specific scenario? If yes what will be that scenario?
Both start with A, and end with %. In the middle part, the first says "one char, then between zero and many chars, then one char", while the second one says "one char, then one char".
Considering that the part that comes after them (the final part) is %, which means "between zero and many chars", I can only see both clauses as identical, as they both essentially just want a string starting with A then at least two following characters. Perhaps if there were at least some limitations on what characters were allowed by the _, then maybe they could have been different.
If I had to choose, I'd go with the second one for being more intuitive. After all, many other masks (e.g. a%%%%%%_%%_%%%%%) will yield the same effect, but why the weird complexity?
For Like operator a single underscore "_" means, any single character, so if you put One underscore like
ColumnName LIKE 'a_%'
you basically saying you need a string where first letter is 'a' then followed by another single character and then followed by anything or nothing.
ColumnName LIKE 'a__%' OR ColumnName LIKE 'a_%_%'
Both expressions mean first letter 'a' then followed by two characters and then followed by anything or nothing. Or in simple English any string with 3 or more character starting with a.
I want to, for each of the following languages on Τ={a, b, c}, construct the corresponding regular expression and regular grammar:
All strings containing exactly three a’s.
All strings containing at most three b’s.
How can I do this?
You may always use unions, concatenations and Kleene stars in addition to the given symbols (unless the task explicitly forbids it). So if you don't know how those work, read up on those first. Afterwards, here's a hint to the first task: take any string that contains three or more b's, say, acbaacbbaacbacb. Each character is either one of the first three b's or not: xxbxxxbbxxxxxxx. So the structure of such a string is a sequence of any characters (or maybe none if it starts with a b), and then a b, then more other characters (maybe), then another b, more characters (maybe), the third b, and finally more characters (maybe). How do you express "any character", and how do you express the alternating sequence of b's and "any character, zero or more times"?
I'm looking for a way to distinguish compound words in a sentence.
Although this is pretty easy in English because there are dashes between words of a compound word (e.g. daughter-in-law), it's not the same in other languages like Persian. In order to detect the words in a sentence we will look for spaces between words. Imagine there isn't a dash to connect these words together, but instead there is a space between them. Fortunately, we already have different records for "daughter" and "daughter in law" in the database. Now I'm looking for an algorithm or SQL query which would first look at bigger chunks of words like "daughter in law" and checks if they exist. If nothing was found, then it should start looking for each word.
Another example would be with digits. Imagine we have a string like "1 2 3 4 5 6". Each digit has a record in the database which corresponds to a value. However, there are extra records for combinations such as "2 3". I want to first get the records for bigger chunks and if there is no record, then check each single digit. Once again, please note that the algorithm must automatically distinguish compounds from singulars.
You can build a Directed Acyclic Word Graph (DAWG) from your dictionary. Basically, it's a trie that you can search very quickly. Once built, you can search for words or compound words pretty easily.
To search, you take the first letter of the word and, starting at the root node of the tree, see if there's a transition to that letter. As you match each letter, you get the next letter and see if there's a transition from the current node of the tree for that letter. If you reach the end of the string, then you know that you've found a word.
If you get to a point where there is not a transition from the current node, then:
if the current node is not marked as the end of a word, then the word you're working with is not a word in the dictionary or a compound word.
if the current node is marked as the end of a word, then you have a potential compound word. You take the next letter and start at the root of the tree.
Note that you probably don't want to implement a DAWG as records in a database.
For English this problem is solved using full text search binary trees (Huffman Encoding Trees), which take advantage of frequency analysis to put the words/alphabet most used on top of the tree.
But for Persian implementing such an algorithm is much more difficult because Persian alphabet combines together and it is not discrete like English. So to answer your question about the algorithm, you have to make a Huffman Encoding Tree based on frequency to be able to search against words.