Array Assignments; Parallelism
CS 536, Mon Nov 22, 2
0
1
0
Activity 12.1: Array Assignment
A. Why?
•
Array assignments aren’t like assignments to plain variables because the actual item to
change can’t be determined until runtime.
We can handle this by e
x
tending our notion
of assignment and/or substitution.
B. Outcomes
At the end of this activity you should:
•
Be able to perform te
x
tual substitution to replace an array element.
•
Be able to calculate the
wp
of an array element assignment.
C. Questions
For each of the questions below, calculate the given weakest precondition. Then try
logically simplifying it to something easier to read.
1.
What is
wp
(
b[0]:= 9
,
x
>
b[i]
)?
(x > b[i])[9/b[0] is x > if i = 0 then 9 else b[i]
fi
2.
What is
wp
(
b[i]:= b[j]
,
b[k] =
0
)?
(b[k] = 0)[b[j]/b[i]] is if k = i then b[j] else b[k]
fi
= 0
3.
What is
wp
(
b[i]:= b[j]
,
b[j] =
z
)?
(b[j] = z)[b[j]/b[i]] is (if j = i then b[j] else b[j]
fi
) = z
㱻
b[j] = z
4.
What is
wp
(
b[i]:= 1
,
b[i] =
b[j]
)?
(Hint: the answer is NOT
1 = b[j]
.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
This is the end of the preview.
Sign up
to
access the rest of the document.
 Fall '08
 cs536
 Computer program, Disjoint sets, Illinois Institute of Technology, Science of Programming, James Sasaki, parallel disjoint

Click to edit the document details