Using the Integer grammar (pg. 27), develop a rightmost derivation for the integer 4520.
Added by Jeremy B.
Step 1
Rightmost derivation for the integer 4520: Start with the rule for Integer: <Integer> -> <Digit> | <Digit><Integer> Apply the rule for <Digit> four times to get 4, 5, 2, and 0 in that order: <Integer> -> <Digit><Integer> -> 4<Integer> -> 45<Integer> -> Show more…
Show all steps
Your feedback will help us improve your experience
Rashmi Prakash and 59 other AP CS educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
Give a recursive definition of the set of positive integers that end with the digit 7. Describe the strings in the set S of strings over the alphabet Σ = {a, b, c} defined recursively by (1) c ∈ S and (2) if x ∈ S then xa ∈ S and xb ∈ S and cx ∈ S. Hint: Your description should be a sentence that provides an easy test to check if a given string is in the set or not. An example of such a description is: S consists of all strings of a's, b's, and c's, with more a's than b's. That isn't a correct description since cab is in S and doesn't have more a's than b's, and also baac isn't in S, but does have more a's than b's. So that attempted description is really terrible. The best way to do this problem is to use the rules to build a bunch of strings in S until a suitable description becomes obvious. (bonus) A set S of ordered pairs of integers is defined recursively by (1) (1, 2) ∈ S and (2, 1) ∈ S, and (2) if (m, n) ∈ S, then (m + 2, n) ∈ S, and (m, n + 2) ∈ S, and (m + 1, n + 1) ∈ S. There is a simple description of the ordered pairs in S. What is it? Your description should be good enough so that you can instantly decide if (12236, 912242) is in S.
Sri K.
a) Construct a phrase-structure grammar that generates all signed decimal numbers, consisting of a sign, either $+$ or $-;$ a nonnegative integer; and a decimal fraction that is either the empty string or a decimal point followed by a positive integer, where initial zeros in an integer are allowed. b) Give the Backus-Naur form of this grammar. c) Construct a derivation tree for $-31.4$ in this grammar.
Modeling Computation
Languages and Grammars
Solve Description to Grammar problem Problem Find a grammar that recognizes the following language: words that are the concatenation of two words of odd length with the same middle symbol (e.g., abbaabab, as this is the concatenation of abb and aabab, two words with b as middle letter). HELP: Grammar Syntax Grammar: 1 production per line start nonterminal: left-hand side of first production Productions: form: S -> X Y | a S b | eps left-hand side: a single nonterminal right-hand side: groups of nonterminals and terminals separated by "|" Nonterminals: form: one single upper case character A-Z Terminals: allowed: abcdefghijklmnopqrstuvwxyz()[]{} Empty word: empty word: ε (write epsilon or eps or e)
Aarya B.
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
Watch the video solution with this free unlock.
EMAIL
PASSWORD