Question

1 Encoding Grammars (30 points In class, we talked about how you could encode a DFA as a string, so that a Turing machine could read in that string M, along with another input string w, and determine whether the DFA M accepts w or not. Now, lets think about how we could do this for grammars. In particular, explain how you would encode a grammar as a string g so that a Turing machine could easily take g and an input string w and determine whether w could be produced by the grammar. Explain how your solution works in general and give the specific string g it would produce from the following grammar:

0 0
Add a comment Improve this question Transcribed image text
Answer #1

import java.util.Scanner;

/* category BSTNode */
category BSTNode
builder */
public BSTNode()

/* creator */
public BSTNode(int n)

/* perform to line left node */
public void setLeft(BSTNode n)

/* perform to line right node */
public void setRight(BSTNode n)

/* perform to induce left node */
public BSTNode getLeft()
come left;
}
/* perform to induce right node */
public BSTNode getRight()
come right;
}
/* perform to line knowledge to node */
public void setData(int d)

/* perform to induce knowledge from node */
public int getData()
come data;
}   
}

/* category BST */
class BST
non-public BSTNode root;

/* creator */
public BST()

/* perform to ascertain if tree is empty */
public Boolean isEmpty()
come root == null;
}
/* Functions to insert knowledge */
public void insert(int data)

/* perform to insert knowledge recursively */
non-public BSTNode insert(BSTNode node, int data)

come node;
}
/* Functions to delete knowledge */
public void delete(int k)
rval)
r = r.getRight();
else
{
found = true;
break;
" id="tip_70">
found = search(r, val);
}
come found;
}
/* perform for inorder traversal */
public void inorder()

non-public void inorder(BSTNode r)

non-public void preorder(BSTNode r)

non-public void postorder(BSTNode r)
making object of BST */
BST bst = new BST();
System.out.println("Binary Search Tree Test\n");
char ch;
/* Perform tree operations */
do
  

Add a comment
Know the answer?
Add Answer to:
In class, we talked about how you could encode a DFA as a string, so that...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Question 1: Design a DFA with at most 5 states for the language L1 = {w...

    Question 1: Design a DFA with at most 5 states for the language L1 = {w ∈ {0, 1}∗ | w contains at most one 1 and |w| is odd}. Provide a state diagram for your DFA. Approaching the Solution --since we haven’t really practiced this type of assignment (i.e. had to define our machine based on only having the language given; not the formal 5 tuples), I am providing the steps for how to work through this; you are...

  • This is related to Machine Learning Problem We have talked about the fact that the sample...

    This is related to Machine Learning Problem We have talked about the fact that the sample mean estimator X = 1 , X, is an unbiased estimator of the mean u for identically distributed X1, X2, ..., Xn: E(X) = p. The sample variance, on the other hand, is not an unbiased estimate of the true variance o2: for V = 12-1(X; - X), we get that E[V] = (1 - 02. Instead, the following bias-corrected sample variance estimator is...

  • Question 8, please. 2. Prove: (a) the set of even numbers is countable. (b i=1 3....

    Question 8, please. 2. Prove: (a) the set of even numbers is countable. (b i=1 3. The binary relation on pair integers - given by (a,b) - (c,d) iff a.d=cbis an equivalence relation. 4. Given a graph G = (V, E) and two vertices s,t EV, give the algorithm from class to determine a path from s to t in G if it exists. 5. (a) Draw a DFA for the language: ( w w has 010 as a substring)....

  • How can we add new words to DFA, maintaining minimality? Maybe, you can advise some completely...

    How can we add new words to DFA, maintaining minimality? Maybe, you can advise some completely different approach to solve the following problem: A program must process two types of queries: Add new word to the language. Check if some word of the language occurs in the input string as a substring. Time and space complexity should be as low as possible. The only solution that I know so far is to rebuild an automaton from scratch every time, using...

  • 2) Planet Velocities and Energy (10 pts) We talked about how planet formation involves the collisions...

    2) Planet Velocities and Energy (10 pts) We talked about how planet formation involves the collisions of bodies (planetesimals, embryos) leading to the growth (and heating) of a planet. Let's think about the velocities and energies involved here. a) The speed of a body in its orbit around the Sun is given by the equation V2= GM.[(2/r) - (1/a)] Here Vis the speed of the body in m/s, G is the gravitational constant, M. is the mass of the Sun...

  • Now, Danielle wants to know how her twins could look so diffe skin and Michael Jr....

    Now, Danielle wants to know how her twins could look so diffe skin and Michael Jr. having dark skin. First, Danielle neede types of twins. Identical twins have exactly the same genes, since in a developing embryo splits into two embryos. Part III: Why do the twins look so different? er twins could look so different, with Michelle having light dark skin. First, Danielle needs to understand that there are two exactly the same genes, since identical twins originate when...

  • 1. If we had two 4-bit signed 2's complement numbers, X--4 and Y-6 and we wanted to compare them, we might calculate X-Y (a) Show that calculation (b) Explain how the result tells us that Y>IX...

    1. If we had two 4-bit signed 2's complement numbers, X--4 and Y-6 and we wanted to compare them, we might calculate X-Y (a) Show that calculation (b) Explain how the result tells us that Y>IX (c) Now show the calculation for Y. X (d) Explain how this also shows us that Y>X 2. We talked about an ALU that takes two 4-bit inputs, A and B, and then generates a 4-bit result, S, based on a 2-bit command, F1FO....

  • Soap Opera Genetics - Genetics to Resolve Family Arguments 1. How could our baby be an...

    Soap Opera Genetics - Genetics to Resolve Family Arguments 1. How could our baby be an albino? Tiffany and Joe have just had a baby and are very surprised to learn that their baby is albino with very pale skin and hair color. Tiffany's sister comes in to visit Tiffany and the new baby, and Joe goes out to talk with his sister Vicky. Did Tiffany have an affair? Joe is very angry. He tells Vicky, "I think Tiffany had...

  • In this written assignment, you have the opportunity to share your thoughts about how to deliver...

    In this written assignment, you have the opportunity to share your thoughts about how to deliver client-centered culturally competent care and work collaboratively with others. The Case of Mrs. G. Mrs. G. is a 75 year old Hispanic woman who has been relatively well all of her life. She had been married for 50 years and had five children. Her children are grown with families of their own. All but one of her children live in other states. Mrs. G.'s...

  • Have you ever considered how we come to understand the world around us? Think about that question for a minute. What is...

    Have you ever considered how we come to understand the world around us? Think about that question for a minute. What is science, and how do we use it to solve real-world problems? In our first discussion, I want to delve into thinking about the nature of biology. This includes what it is, the major themes, and how we come to form claims or knowledge. You should spend approximately 3 hours on this assignment. Instructions Use the text readings and...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT