[6 pts] C has three forms of integer constants: decimal, octal, and hexadecimal. The value 30...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
[6 pts] C has three forms of integer constants: decimal, octal, and hexadecimal. The value 30 is expressed as 30, 036, and Oxle in these forms, respectively. We have shown in lecture that the decimal and octal constants can be defined by regular expressions: octal = 0[0-7] + decimal = 0 | [1-9] [0-9]* (a) [1] Give a regular expression for hexadecimal constants. (Assume only lower cases letters are used.) (b) [3] Now consider two subsets of integer constants: i. the set of even constants (e.g. 10, 012, and 0xc are three such constants, all have an even value of 10); and ii. the set of odd constants (e.g. 11, 013, and Oxd are three such constants, all have an odd value of 11). For each set, give three regular expressions for the three constant forms. (There should be a total of six regular expressions.) You should use conventional regular expression notations, as shown in class (Week 2 slides). Python RegEx's special sequences are not allowed. (Hint: Be careful with zeros. Which constant form does each of the following literals represent, 0, 00, and 000?) (c) [2] The above two sets are defined with a reference to integer values (i.e. even vs odd), which is not exactly a syntax term. Do you think it's coincidental that you are able to define regular expressions for those sets based on a value-oriented specification? Or do you think it can be generalized to other sets defined with a value reference? Provide a convincing argument; use examples if necessary. [6 pts] C has three forms of integer constants: decimal, octal, and hexadecimal. The value 30 is expressed as 30, 036, and Oxle in these forms, respectively. We have shown in lecture that the decimal and octal constants can be defined by regular expressions: octal = 0[0-7] + decimal = 0 | [1-9] [0-9]* (a) [1] Give a regular expression for hexadecimal constants. (Assume only lower cases letters are used.) (b) [3] Now consider two subsets of integer constants: i. the set of even constants (e.g. 10, 012, and 0xc are three such constants, all have an even value of 10); and ii. the set of odd constants (e.g. 11, 013, and Oxd are three such constants, all have an odd value of 11). For each set, give three regular expressions for the three constant forms. (There should be a total of six regular expressions.) You should use conventional regular expression notations, as shown in class (Week 2 slides). Python RegEx's special sequences are not allowed. (Hint: Be careful with zeros. Which constant form does each of the following literals represent, 0, 00, and 000?) (c) [2] The above two sets are defined with a reference to integer values (i.e. even vs odd), which is not exactly a syntax term. Do you think it's coincidental that you are able to define regular expressions for those sets based on a value-oriented specification? Or do you think it can be generalized to other sets defined with a value reference? Provide a convincing argument; use examples if necessary.
Expert Answer:
Related Book For
Posted Date:
Students also viewed these algorithms questions
-
ccn2 java solve them all . . . r2 e1 e2 box r2 Write sound typing and subtyping rules for these constructs. [5 marks] Now suppose that we add to this calculus the type variables and bounded universal...
-
ccm1 java attend all . . . r2 e1 e2 box r2 Write sound typing and subtyping rules for these constructs. [5 marks] Now suppose that we add to this calculus the type variables and bounded universal...
-
The following table includes transactions carried out by Ram Horn Corporation, as well as columns for each of the three categories found in the statement of cash flows: operating, financing, and...
-
Speihler is an integrated manufacturer of forest products-lumber, pulp, paper and Specialty cellulose-serving customers worldwide. Speihler has operations in North America and Europe with some 4,000...
-
Falling-cylinder viscometer (see Fig. 2C.4) A falling-cylinder viscometer consists of a long vertical cylindrical container (radius R), capped at both ends, with a solid cylindrical slug (radius KR)....
-
Define and distinguish among subject matter, personal, and in rem jurisdiction.
-
The ownermanager of Good Guys Enterprises obtains utility from income (profit) and from having the firm behaves in a socially conscious manner, such as making charitable contributions or civic...
-
Discussion questions: With reference to the reading explain what Wolf means by a sane deep self. Do you think that Jojo is morally responsible (viz., deserving of praise and blame for his actions)?...
-
AW 200 ( 41.7 wide-flange beam (see Table E-1(b). Appendix E) is simply supported with a span length of 2.5 m (see figure). The beam supports a concentrated load of 100 kN at 0.9 m from support B. At...
-
Question 13 The expected P/E multiple of ABC is 40 and the expected P/E multiple of XYZ is 8. Why are P/E multiples of the two stocks so different? O ABC's expected growth rate is lower than that of...
-
Consider the following matrix: A = -1 0 41 3 1 1 3 2 4] A) Write the polynomial equation that needs to be solved to derive eigenvalues of matrix A. Subsequently, solve the nonlinear equation and...
-
What gross proceeds (before any commissions on the trade) would an investor receive if she sold a $10,000 face value T-bill that matures October 12, 2017?? $9.955.50? $9,050.00? $9.961.50? $5.550.42...
-
What is the role of the Golgi complex within the cell cytoplasm?
-
What is the survival revenue for a company if: - Revenue is $ 1 , 0 0 0 , 0 0 0 - COGS is $ 5 0 0 , 0 0 0 - Cash fixed costs ( CFC ) is $ 2 5 0 , 0 0 0 .
-
Which conditions are taken into account when estimating the fair value of the shares or share options at the grant date? All vesting conditions Service conditions Market conditions Non - market...
-
Benville Hospital uses a job - order costing system for all patients who have surgery. The following information is available: Budgeted indirect costs-pre - operating room Budgeted indirect...
-
Recall that Chapter 8 described the binary search algorithm for finding a particular entry in an ordered list. The idea behind binary search is to begin looking in the exact center of the list. If...
-
In Example 13.38 (Figure 13.15), suppose we replaced the middle four lines of procedure P with and the middle four lines of procedure V with What is the problem with this new version? Explain how it...
-
Write the equivalent of Figure 6.5 in C# or Ruby. Write a second version that performs an in-order enumeration, rather than preorder. Figure 6.5: class BinTree: def -_init_ (self): # constructor...
-
Write regular expressions to capture the following. (a) Strings in C. These are delimited by double quotes ("), and may not contain newline characters. They may contain double-quote or backslash...
-
Following up on question number 3, assume the school conducts a manifestation determination meeting. Tim attends the meeting with his parents. At the meeting, Tim tells the team that smoking helps...
-
Which is an advantage to an employee who participates in a profit-sharing plan? A. Employee does not have to make investment decisions. B. Graded vesting schedule. C. Older employees receive the...
-
Which of the following is not a characteristic of a defined benefit plan? A. A guaranteed retirement benefit. B. Risk of preretirement inflation assumed by employer. C. Benefits based upon the...
Study smarter with the SolutionInn App