Draw a transition diagram for the arcade system

Assignment Help Data Structure & Algorithms
Reference no: EM132214000

Assignment -

Consider the following definition of trees that expands on the variety already seen on homework assignments:

TREE ::= leaf<<N>>| node <<N x TREE x TREE>>

It says that a tree is either a leaf which has a numeric value, or it is a (binary) node which has a value and two sub-trees.

Here are some examples of trees:

1771_figure.png

Tree A can be described as node(4, leaf (5), leaf (9))

and tree B as node(1, node(2, leaf (3), leaf (5)), leaf (4))

1. Give the description of tree C in the same format.

Now consider the following function definitions:

794_figure1.png

2. Write axiomatic definitions for two functions: totalsum, which adds up all the numeric values in the tree; and maxsum, which returns the maximum sum of numeric values along a single branch of the tree from root to leaf. For example, the maxsum for tree C above is 2+3+5+7 = 17.

3. Prove the following by structural induction: ∀t : TREE • maximum(t) ≤ totalsum(t)

Consider the following arcade game credit management system:

  • The interface consists of a slot for depositing coins, a push button labeled "1", and a push button labeled "2".
  • Up to two coins can be deposited, each coin being worth one credit. If there are two credits, no more coins will be accepted by the machine.
  • A one-player game costs one credit, and can be initiated by pressing the "1" button when there is at least one credit.
  • A two-player game costs two credits, and can be initiated by pressing the "2" button when there are two credits.
  • While a game is in progress, coins are not accepted, and pressing the "1" and "2" buttons have no effect. The credit management system remains in the same state until the game is complete. Once the game is over, the system becomes active again.

The following define the set of states, the initial states, and the actions for a state machine that models this system:

S == [credits : {0, 1, 2}; game : {none, 1p, 2p}],

I = {s : S | credits = 0 Λ game = none};

A = {coin, 1_button, 2_button, game over}

The transitions of the system can be any set of transitions that accurately model the description given above of the machine's behaviour. If there is any ambiguity in the above description, there may thus be more than one possible set of transitions that accurately model the described behaviour.

Answer each of the following questions with respect to the above model.

1. Draw a transition diagram for the arcade system. You may name individual states if you wish. For each state, be sure to indicate clearly the values of all state variables. Don't forget to label transitions.

2. Do each of the following:

(a) Rewrite the set δ by enumeration (i.e., list all the triples). You may use the names you assigned to states in question (1) if you wish.

(b) Give the pre- and post-conditions of each action.

3. Answer each of the following:

(a) What happens if you press the 1_button when there are no credits?

(b) Can the game_over action fire if no game is in progress? How can you tell?

(c) What happens if you press the 2_button when a one player game is in progress?

(d) How many initial states are there in this system?

(e) Give the event-based trace of the execution in which a one player game, then a two player game are paid for (with no extra coins being inserted prior to each game) and then played, in that order.

4. Give an FSP specification of the arcade management system.

Consider the following enhanced arcade game credit management system:

  • The interface consists of a slot for depositing coins, a push button labeled "1", a push button labeled "2", and a push button labelled "coin return".
  • There is a minimum of zero credits, and a maximum of ten. Each coin deposited adds one credit, up to the maximum of ten. Once there are ten credits, any coin deposited will be returned.
  • Pressing the "coin return" button at any point will set the credits to zero, and the appropriate number of coins will be returned. E.g., if the button is pressed when there are two credits, two coins should be returned.
  • A one-player game costs one credit, and can be initiated by pressing the "1" button when there is at least one credit.
  • A two-player game costs two credits, and can be initiated by pressing the "2" button when there are two credits.
  • While a game is in progress, coins will be accepted, and the number of credits updates while the game is still in progress.
  • While a game is in progress, the "coin return" button is enabled. Pressing the "coin return" button should not end the game.
  • While a game is in progress, the "1" and "2" buttons are disabled. Pressing them does not change the state of the credit management system.

Here is the beginning of a Z specification for this system: GAME ::= none | one | two

1. Write an InitArcadeCreditSystem schema that defines the initial state for the system. Explain why this initial state is consistent with the state space invariant given above.

2. Write an operation CoinReturn that fires when the user presses the coin return button.

3. Write an operation 1_button that fires when the user presses the button labelled "1".

4. If the 1_button operation is not robust, use the schema calculus to make a robust version of the operation (be sure to define any auxiliary schemata you use in the process); if the operation is robust, explain why that is the case.

Note - Please adhere to deadline otherwise this whole exercise will be futile and the waste of money and time for me.

Attachment:- Assignment File.rar

Reference no: EM132214000

Questions Cloud

Prepare a direct materials purchases budget : A company manufactures widgets. Based on an analysis, we find that each widget needs 3/4 pound of gunk. The following is information on the budgeted production
What would toyota have to do to recover fully : Can Volkswagen recover from these recall problems? If so how long will that take: What would Toyota have to do to recover fully?
How much of charlotte costs can be deducted : Charlotte traveled to Annapolis to attend a three-day business conference. After her meetings concluded, she stays 2 additional days sightseeing.
What is woolard total depreciation deduction for the year : Woolard Supplies (a sole-proprietorship) has taxable income in 2018 of $240,000 before any depreciation deductions (§179, bonus, or MACRS).
Draw a transition diagram for the arcade system : Draw a transition diagram for the arcade system. For each state, be sure to indicate clearly the values of all state variables
Define the financial statement effects : Bonds Payable: On January 1, 2014 ABC issued $800,000.00 of 20-year, 11% bonds for $739,814.81, yielding a market (yield) rate of 12%. Interest is payable.
Explain the importance of each type : Using the firm you are auditing, thoroughly outline the evidence you will gather. Explain the importance of each type and how you will gather and evaluate it.
Present a case law decision related to a tax topic : BBAL501 TAXATION LAW - The presentations should summarise the issues and decisions relevant to the case - good presentation will include a good analysis
What is the ending total asset balance : Net sales are $3473000, beginning total assets are $ 1416000, and the asset turnover is 2 times. What is the ending total asset balance?

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  What are limitations of arrays

What is an array? What are limitations of arrays? Give an example to show the usefulness of arrays - Write a program to implement a stack which contains

  Define a recursive function count

Define a recursive function count

  Which includes and algorithm that takes an array

Write an application which includes and algorithm that takes an array, selects the high and low integer from the array of integers with each pass and builds a new array of integers by inserting the high and low selection with each pass. Your ..

  Pseudocode program

Write a program that inputs the first name, middle initial (without the period), last name, age, salary and sex of new employee. Then displays that person's name with the first name first, middle initial followed by a period, and last name then ag..

  Find the height of its left sub tree and the height

For each of the nodes, find the height of its left sub tree and the height of its right sub tree.

  Explain benefits of isdn

Sometimes ISDNs are used in locations that do not support DSL or cable modem connections. Your selections may be analog modems or an ISDN connection in those remote locations.

  Single versus parallel arrays

Single versus Parallel Arrays

  Using java, design and implement an api euclidean graph

Using Java, design and implement an API EuclideanGraph for graphs whose vertices are points in the plane that include coordinates.

  Conceptual model entity relationship diagram

Assume you are asked you to create a new entity-relationship diagram for a corporation for a customized shipment tracking system.

  Computing entropy of plaintext message

Compute the entropy of the plaintext message?

  Implementing an item-based recommendation system

CSC385 Data Structures and Algorithms Project. For the semester project, you will be implementing an item-based recommendation system. Recommendation systems are widely used on the web for recommending products and services to users based on their ..

  List the inputs any processes calculations and outputs

Your goal is to solve the following simple programming exercise. You have been contracted by a local antique store to design an algorithm determining the total purchases and sales tax. List the inputs, any processes, calculations, and outputs

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd