Question

In: Computer Science

According to the loop invariant theorem, a valid loop invariant ?(?)I(n) must have the property that...

According to the loop invariant theorem, a valid loop invariant ?(?)I(n) must have the property that

Select one:

a. ?(?)=0I(n)=0 after a finite number of steps.

b. After the loop, ?→?(?)P→I(N) where ?P is the postcondition.

c. ?(0)→?I(0)→Q, where ?Q is the precondition.

d. None of the other answers are correct

Solutions

Expert Solution

THE LOOP INVARIANT THEOREM

A->B means that A implies B

(d) is the correct answer as none of the option is correct

(a) is wrong because I(n) does not beomes 0 after a finite number of steps, it is the G which becomes 0 after a finite number of steps.

(b) is wrong because after the loop I(N) implies P as given in point IV of algorithm

(c) is wrong because Q implies I(0) as given in point I of the algorithm


Related Solutions

Find a loop invariant (I) for the following while loop with the post-condition {Q: S=1}, where...
Find a loop invariant (I) for the following while loop with the post-condition {Q: S=1}, where S is an integer and the operator / represents an integer division. Show your work step by step to receive full credit. while (S > 1) do S = S / 2; }
What property must emulsifiers have that fats lack?
What property must emulsifiers have that fats lack?
A contract is a set of legally enforceable promises. A valid contract must have agreement/ offer...
A contract is a set of legally enforceable promises. A valid contract must have agreement/ offer consideration, legal object/purpose, and parties with legal capacity. Sometimes two parties will enter into a contract with the intent to benefit a third party. In these situations, a third-party beneficiary contract is formed. Third-party contracts are difficult to follow with the rights and obligations of the parties. You are required to create a contract (keep it simple-one page). You will select the subject of...
I need to generate a loop for 1,000 Monte Carlo iterations in R. I have two...
I need to generate a loop for 1,000 Monte Carlo iterations in R. I have two randomly generated standard normal variables for this with sample sizes of 100.
The owner of the property must sign the contract to confirm they have received a special...
The owner of the property must sign the contract to confirm they have received a special document. What is the document and what does it contain? it is question of certificate 4 in building and construction from assesment of CPCCBC4008B Conduct on-site supervision of building and construction projects
I have n books with n different titles. I want to put them on the shelves...
I have n books with n different titles. I want to put them on the shelves in my library. How many different ways are there to arrange them on one shelf? On two shelves? On k shelves?
I have to use a sentinel while loop to complete the following task in a java...
I have to use a sentinel while loop to complete the following task in a java program, I want to see how this is executed so I can better understand how the sentinel while loop works. Thank you! Convert Lab 10 from a counter controlled WHILE loop to a sentinel WHILE loop. Do the following: Prompts the user to enter a grade or a -1 to quit. IF the user entered a -1 THEN Display a message that the User...
Use the Central Limit Theorem to show i. Po(λ) → N(µ, µ) for large µ. ii....
Use the Central Limit Theorem to show i. Po(λ) → N(µ, µ) for large µ. ii. Bin(n, π) → N(nπ, nπ(1 − π)) for large n, provided neither nπ nor nπ(1 − π) is too small
I have a project about how is calculas related to mechanical engineer. I must have a...
I have a project about how is calculas related to mechanical engineer. I must have a total of 500 word can someone help me please?
Hello, I Have create this code and Tried to add do while loop but it gives...
Hello, I Have create this code and Tried to add do while loop but it gives me the error in string answar; and the areas where I blod So cloud you please help me to do ( do while ) in this code. // Program objective: requires user to input the data, program runs through the data,calcualtes the quantity, chacks prices for each iteam intered,calautes the prices seperatly for each item, and calculates the amount due without tax, and then...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT