# Descrete Math week 4

Task Background:  This assignment involves solving problems by using various discrete techniques to model the problems at hand. Quite often, these models form the foundations for writing computer programming code that automate the tasks. To carry out these tasks effectively, a working knowledge of sets, relations, graphs, finite automata structures and Grammars is necessary.

Part I: Set Theory

Look up a roulette wheel diagram. The following sets are defined:

• A = the set of red numbers
• B = the set of black numbers
• C = the set of green numbers
• D = the set of even numbers
• E = the set of odd numbers
• F = {1,2,3,4,5,6,7,8,9,10,11,12}

From these, determine each of the following:

• AâˆªB
• CâˆªE

Part II: Relations, Functions, and Sequences

The implementation of the program that runs the game involves testing. One of the necessary tests is to see if the simulated spins are random. Create an n-ary relation, in table form, that depicts possible results of 10 trials of the game. Include the following results of the game:

• Number
• Color
• Odd or even (note: 0 and 00 are considered neither even nor odd.)

Also include a primary key. What is the value of n in this n-ary relation?

Part III: Graphs and Trees

Create a tree that models the following scenario. A player decides to play a maximum of 4 times, betting on red each time. The player will quit after losing twice. In the tree, any possible last plays will be an ending point of the tree. Branches of the tree should indicate the winning or losing, and how that affects whether a new play is made.

Part IV: Automata Theory, Grammars and Languages (There are 2 questions for this part)

(1) A gate with three rotating arms at waist height is used to control access to a subway in New York city. Initially, the arms of the gate are locked preventing customers from passing through. Unlocking the arms requires depositing a token in a slot, which allows the arms to rotate to a complete turn which allows one customer to push through and enter. Once the customer passes through the arms are then locked again until another customer deposits another token in the slot.

The gate has two states: LOCKED and UNLOCKED. It also has two inputs: TOKEN and PUSH. When the gate is locked, pushing the arm of the gate has no effect regardless of how many times it is pushed. The input TOKEN changes the state from LOCKED to UNLOCKED. When the gate is in the UNLOCKED state, inserting additional tokens has no effect on the state. But when in the UNLOCKED state, a PUSH input changes the state to LOCKED.

(i). Provide a transition table showing each state, the inputs, and the resulting new states for each input

(ii). Represent your transition table into a digraph (transition diagram)

(2) Here is a context-free grammar that can be used to generate algebraic expressions via the arithmetic operators (addition, subtraction, multiplication, and division), in the variables p, q, and r. The letter E stands for expression:

Rule 1: E â€”â€º p

Rule 2: E â€”â€º q

Rule 3: E â€”â€º r

Rule 4: E â€”â€º E + E

Rule 5: E â€”â€º E â€“ E

Rule 6: E â€”â€º E X E

Rule 7: E â€”â€º E/E

Rule 8: E â€”â€º(E)

(i). Use the above grammar to derive the string given by the mathematical expression E =  (p + q) X p â€“ r X p/(q + q)

(ii). Provide a parse tree for this derivation
{"found_math": false, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "url": "https://topnursingtutors.com/descrete-math-week-4/", "fetch_time": 1619097757000000000, "content_mime_type": "text/html", "warc_filename": "crawl-data/CC-MAIN-2021-17/segments/1618039610090.97/warc/CC-MAIN-20210422130245-20210422160245-00189.warc.gz", "warc_record_offset": 654584445, "warc_record_length": 11933, "token_count": 845, "char_count": 3366, "score": 4.125, "int_score": 4, "crawl": "CC-MAIN-2021-17", "snapshot_type": "latest", "language": "en", "language_score": 0.9073808789253235, "file_path": "/sailhome/yjruan/project/latent-lm/data/processed/finemath-4plus/finemath-4plus/train-00028-of-00064.parquet"}