# Thread: 2 Questions from ets sample '99

1. Good post? |
13. Suppose one wishes to be certain that after execution of the statement

Code:
```if a > b then
x := a```
the value of x will equal the value of a.
Of the following, which is the weakest (least restrictive) condition that must necessarily hold before execution of that statement?

Code:
```A. (x = a)  or (a > b)
B. (x = a) and (a > b)
C. a > b
D. x > b
E. x = a```
29.
Code:
``` S -> A0B
A -> The GRE Big Book|0
B -> AA|1```
What is the number of terminal strings of length 5 generated by the context-free grammar shown above?

(A) 4
(B) 5
(C) 6
(D) 7
(E) 8

I did solve this problems to my best, but no match with ETS's answer keys

AlbaLed

2. Good post? |
13.
Certainly a > b must hold, oth. you wont enter the if.

weakest (least restrictive) condition among the choices thus
with (x = a) or (a > b) you enter the if.
Don't mind why x = a, or x = sth else, or sth else = sth else.
The important thing here is (a > b) and any stupid thing ORed with it.

29.
I hate those questions by the way. You will try one by one and hope
you will not miss anything.

3. Good post? |
So you're saying answer is B ?

If that is the case, I think that is a strong condition because if either of the clauses is true, then after the execution x is definitely a.

Did you check choice D, by any chance? Is that a strong condition?

Thanks
AlbaLed

4. Good post? |
No I say the answer is a
A. (x = a) or (a > b)

What I understand from weakest(least restrictive) condition is that it should contain something that must necessarily hold, in this case (a>b)
and something that does not affect the execution (in this case (or (x=a).

Strong condition is something that should hold always, in this case (x > a) is a strong condition.

5. Good post? |
Sorry I meant A,

My main concern is about D, because it only contains a condition which does not affect the execution at all. I think A is a weak condition, but D is weaker. What do you think maked D a stonger conditiona than A?

AlbaLed

6. Good post? |
Here is a usefull definition

"The weakest precondition is the least restrictive precondition that will guarantee the validity of the associated postcondition (x=a in our case)"

So D in this case is not even a valid precondition

AlbaLed

7. Good post? |
Sorry this time, I misspelled it.

Strong condition is something that should hold always, in this case (x > a) is a strong condition.
IT should be a > b by the way.

Yes you have given the answer yourself. A is the weakest, C is the strongest, B, D, E does not satisfy the conditions.

Also you should check out the exact wording in the question

Suppose one wishes to be certain that after execution of the statement

if a > b then
x := a

the value of x will equal the value of a.
Of the following, which is the weakest (least restrictive) condition that must necessarily hold before execution of that statement?

B, D, E are out of the table right away.

8. Good post? |
Thanx

here is a useful link that describes semantics
http://clem.mscd.edu/~gordona/csi3210/lects/lect19.html

Can you try 29 and see what you get?

AlbaLed

9. Good post? |
29. (B)

Since S -> A0B
to get a string of length 5, the possibilities are:
Code:
``` len(A) | len(B)
--------|-------
4     | 0         impossible
3     | 1         two: 00101 10001 *
2     | 2         one possiblity: 11000
1     | 3         two: 00011 00110 **
0     | 4         impossible

* (3,1):  S->A0B->BB0B->AAB0B->00101
S->A0B->BB0B->BAA0B->10001

** (3,2): S->A0B->A0AA->A0BBA->00110
S->A0B->A0AA->A0ABB->00011```

10. Good post? |
I am not sure if B and E are off the table, since they would also gurantee the post-condition. Also not sure if "strongest" could be defined as a>b, it could be x=a as well. Weakest condition is the one which could cover iff (if and only if) test.

Page 1 of 2 12 Last

There are currently 1 users browsing this thread. (0 members and 1 guests)

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•

SEO by vBSEO ©2010, Crawlability, Inc.