Question
1.Each square on a chess board can be described by a letter and number, such as g5 in this example: The following pseudocode describes an
1.Each square on a chess board can be described by a letter and number, such as g5 in this example: The following pseudocode describes an algorithm that determines whether a square with a given letter and number is dark (black) or light (white).
If the letter is an a, c, e, or g: If the number is odd: color = "black" Else: color = "white" Else: If the number is even: color = "black" Else: color = "white"
Trace this algorithm by making a table such that:
The table headers are the variables (one column per variable)
The first row shows the initial (assumed) values of the variables
Each following row shows a value change in a variable
2.Give a set of four test cases for the algorithm from question 9 that covers all branches.
3.In a scheduling program, we want to check whether two appointments overlap. For simplicity, appointments start at a full hour, and we use military time (with hours 024). The following pseudocode describes an algorithm that determines whether the appointment with start time start1 and end time end1 overlaps with the appointment with start time start2 and end time end2.
If start1 > start2: s = start1 Else: s = start2 If end1
Using the table described in question 9, trace this algorithm with each of the following:
an appointment from 1012 and one from 1113
an appointment from 1011 and one from 1213
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started