-1

I am looking at the truth table for following pseudocode.

IF year = 11 AND (grade < target OR target >7) THEN
   SET revision_class TO true
END IF

I want to know whether the below truth table is correct or not. If it is correct, please explain me the row 5. Because it looks not correct to me:

Truthtable

trincot
  • 317,000
  • 35
  • 244
  • 286
Norvin
  • 21
  • 4
  • Welcome to Stack Overflow. Please take the [tour] to learn how Stack Overflow works and read [ask] on how to improve the quality of your question. Then check the [help/on-topic] to see which questions are on-topic on this site. It is unclear what you are asking or what the problem is. You have not shown your truth table or the online truth table. And you have not asked any question. – Progman Mar 14 '23 at 18:34
  • 1
    Row 5 is indeed incorrect. – Progman Mar 14 '23 at 18:49
  • 1
    So it should be 0 instead of 1 right. Then only 3 times conditions is full-filled. Also last column is unnecessary. Am I right ? – Norvin Mar 14 '23 at 18:52

1 Answers1

1

Indeed, the last column has an error in the 5th row. That column should be exactly the same as the one-but-last column.

Another thing that is not right is the pseudo code: it is incomplete. If the IF condition is not true, then the variable revision_class is undefined. To have this truth table, the pseudo code should start by setting that variable to false:

SET revision_class TO false
IF year = 11 AND (grade < target OR target > 7) THEN
   SET revision_class TO true
END IF

Or more direct:

SET revision_class TO (year = 11 AND (grade < target OR target > 7))

Normally you would first list the input booleans in the truth table, so I would put the column Year = 11 before the OR one. As the last column really is a copy of the previous one, you might exclude it, but I will keep it in here:

grade < target target > 7 Year = 11 grade < target
OR target > 7
Year = 11 AND
(grade < target
OR target > 7)
revision_class
0 0 0 0 0 0
0 0 1 0 0 0
0 1 0 1 0 0
0 1 1 1 1 1
1 0 0 1 0 0*
1 0 1 1 1 1
1 1 0 1 0 0
1 1 1 1 1 1
trincot
  • 317,000
  • 35
  • 244
  • 286