# Questions on Rules and Procedures

What words are missing from this diagram

## A simple function

Here is an informal specification for a simple function or action in a program.
` If I is equal to 1 then change I to 2 and vice versa.`
1. Any questions?
2. What are the variables: given and goal?
3. Any questions?

4. Express the function as a table.
5. Any questions?

6. Express the table in pseudo-code.

7. Express the pseudo-code in your favorite language.

. . . . . . . . . ( end of section A simple function) <<Contents | End>>

## DARPA Grand Challenge

1. Suppose you are working on a team who are building a robot for a DARPA grand challenge project -- these involve robotic vehicles. Your team has a winning robot vehicle when tested in the desert but the new test involves driving in a town and following the traffic regulations correctly. Your specific task is to express the rules governing Stop Lights in California. Your software can see which lights are lit (Red, Green, Amber, ) and must output messages like: "stop", "go", "turn left", "turn right", etc.

2. What are the variables and their values?

3. Draw up a table showing how the given data maps into the outputs.

4. The test run will probably include the intersection and entrance into the campus, of "Little Mountain Driveway" and "North Park". You may use your computer to research the topic. Express the rules as a table. Make sure they are (1) Complete and (2) Consistent.

. . . . . . . . . ( end of section DARPA Grand Challenge) <<Contents | End>>

## Decoding the Elements

1. Find the periodic table of elements [ Periodic_Table#Standard_periodic_table ] which shows for each element its short name (H, He, Li, Be, ... Uuo) and the matching atomic number. One of the nastiest pieces of code I ever hade to write, read in one or two characters coding elements 1 thru 83 (no radioactive ones!) and to recognize and return the atomic number. So, for example,
` 	Al`
became 13 and
` 	Ag`
became 47. Given "H " (note the space) it responded 1, "He" ->2, "Hg" -> 80, ... Any questions?

2. How qould you handle this in a program?
3. Complete the following pseudo-code:
` 	READ CHARACTERS C1, C2;`
` 	...`
` 	OUTPUT AtomicNumber;`

. . . . . . . . . ( end of section Decoding the Elements) <<Contents | End>>

1. Express the procedure for doing the Critical Path Method (CPM) in pseudo-code.

2. Express the method of Cost-Benefit Analysis in pseudo-code.

Draw up a table that shows all possible cases when solving a quadratic equation
1. a*x^2 + b*x + c = 0

You may use any resources -- online or hard-copy to get the formulas.

Hint 1: the cases include both real and imaginary solutions, double roots, and special cases where a, b, and/or c = 0. Include one case where there no x that satisfies the equation!

Hint 2: Do the well known case first and then ask when the formulas in it fail. Write conditions and formulas to handle these exceptions.

. . . . . . . . . ( end of section Solving a Quadratic Equation) <<Contents | End>>

3. List the techniques in this set of notes (from memory). Which are best for physical models and which for logical models?

4. Here TBA is a set of requirements expressed informally. Use any techniques that you know do discover any incompleteness and/or inconsistencies in these requirements.

5. Here are two sets of requirements concerned with the encoding of Universal Resource Locators in the HTML. Do they always describe the same encoding? If they don't give an example and how it is different.
• URL_encoding::=
Net
Each character in the string is encoded as follows: If it is a letter or a digit it is copied, if it is a space then it is replaced by a plus sign. Otherwise the character is replaced by a percent sign followed by the hexadecimal code for the ASCII code of the character.

(End of Net)

• IE4_URL_encoding::=
Net
Each character in the string is encoded as follows: If it is a letter or a digit it is copied, if it is a space then it is replaced by a plus sign. Plus signs are copied as is. Otherwise the character is replaced by a percent sign followed by the hexadecimal code for the ASCII code of the character.

(End of Net)

6. Find a set of complicated requirements like the Discounts'RUs example and attempt to use any of the techniques in this section of notes to document it. Can you discover any inconsistencies or any incompleteness?

7. What do you use an activity diagram or flowchart for?
8. How does a DFD differ from an activity diagram -- list all the ways.
9. How does a ERD differ from an activity diagram -- list all the ways.
10. How does a state machine differ from an activity diagram -- list all the ways.

11. What items of meta-data need to be stored in a data dictionary about a simple element like a social security number?
12. What items of meta-data are needed to document a record?

13. What is a scenario?

14. Describe Pseudo-code including the three structures.

15. How is logic and mathematics is used in detailed models of systems and software?

16. What is a tree diagram? Include an example in your definition.
17. Draw a tree diagram that determines if a year (A.D.) is a leap year or not.

18. What do we call a program that is not useful but demonstrates some of the requirements on a system? How does this differ from an iteration?

19. Draw a flowchart/activity diagram that models cost benefit analysis.

20. Draw a state chart (state machine) to model the evolution of a bug in a issur tracking system. Isuues start out as "New" and are classified as "Duplicate", "Invalid", "Valid". Valid issues are then "Assigned" and then become "Fixed" or "Abandoned". Abandoned bugs are reassigned. Fixed bugs leave the systems, as do Duplicate and Invalid issues.

## Final Question -- Process Details in UML -- 25 points

When I hand graded work back to a large class I often fold it so that only the student's name is visible and sort the work so that the names are in alphabetical order. You can find your work rapidly by using the "divide-and-conquer" binary search algorithm: You divide the work into two halves and look at the piece of work at the division. If this is your work you remove it and hand the rest (unchanged) to the next person. Otherwise if it's name is before your name in the alphabetic sequence then you repeat the same procedure on the second half. Else the name is after yours and you repeat the same binary search procedure to the first half of the work. Draw a correct UML activity diagram for this process. Points are for using the UML notation correctly, an informal flowchart can not earn more than 15 points.

. . . . . . . . . ( end of section Questions on Rules and Procedures) <<Contents | End>>

# Abbreviations

1. TBA::="To Be Announced".
2. TBD::="To Be Done".