anonymous
  • anonymous
Give a postcondition for the following algorithm that completely describes how the final value of i is related to x. Precondition: x is a positive odd integer. i ← 0 while i < x do i ← i + 2 i=???
Mathematics
  • Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
SOLVED
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
jamiebookeater
  • jamiebookeater
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
anonymous
  • anonymous
@Zarkon
anonymous
  • anonymous
@Loser66
Loser66
  • Loser66
It' s computer science, sweeties. tag @e.mccormick. He is the right one. (computer science student)

Looking for something else?

Not the answer you are looking for? Search for more explanations.

More answers

e.mccormick
  • e.mccormick
Does i ← 0 mean i=0? and i ← i + 2 mean i = i + 2?
e.mccormick
  • e.mccormick
Seems like some sort of meta language or logic description, and not really programming. However, the principal should be the same. A while loop continues as long is the condition is true. Therefore, because x is any positive, odd integer, and i starts at 0, the first time through i will become 2. If x is 1, this all ends right there. If x is not 1, then it is still greater than 2 and the loop starts over. Now i becomes 4. Again, is x 3? If so, the loop condition is met and it ends. Otherwise it repeats. This happens as many times as needed until i passes x, but it stops as soon as i passes x. Therefore.... can you see what i would have to be at that point?
anonymous
  • anonymous
seems like the answer is not that simple..but thx for ur input
anonymous
  • anonymous
thx @Loser66
Loser66
  • Loser66
hahaaha why do you say thank you to me? e.mccormick helps you, right?
Loser66
  • Loser66
wrong address, sweeties.!!
e.mccormick
  • e.mccormick
hmm... What language is it in. The ← may have a different meaning. Otherwise, \(i=x+1\) is the postcondition.
anonymous
  • anonymous
I don't know what language it is..
anonymous
  • anonymous
I know loser66, but u hooked it up lol
Loser66
  • Loser66
e.mccormick asks you about the program you study in C, C++ or java?
e.mccormick
  • e.mccormick
Not just those. I feel malia667 got the question. Like I thought, it sounds like it is just a meta language or something manufactured for the course. Here is a reference to the sort of pre-post analysis I did to come up with my answer. It should be correct, so I don't know why it would fail to follow the same rules they describe there. http://cs.engr.uky.edu/~lewis/essays/algorithms/correct/correct1.html
anonymous
  • anonymous
ok lemme take a look..yes its more of a general question
anonymous
  • anonymous
@oldrin.bataku any ideas on this one?
anonymous
  • anonymous
I can handle any CS or programming questions as well
anonymous
  • anonymous
Note that since \(x\) is odd and \(i\) is even, we end up with the smallest even \(i\) that is greater than our odd \(x\) -- which happens to just be \(i=x+1\).
anonymous
  • anonymous
ok just like what e.mccormick said..got it thanks :) let me see if that works
anonymous
  • anonymous
It should make intuitive sense that repeatedly adding \(2\) to \(0\) gives you successive even integers, and the loop terminates once we reach an even number greater than or equal to \(x\) -- it'll always \(>\) since \(x\) is odd and thus we see it is necessarily \(i=x+1\)

Looking for something else?

Not the answer you are looking for? Search for more explanations.