Question: Consider this algorithm countEven(A): Input: une sequence Table of integers Output: the number of even numbers in the table. Example: countEven({20, 44, 45, 32, 5,

Consider this algorithm countEven(A): Input: une sequence Table of integers Output: the number of even numbers in the table. Example: countEven({20, 44, 45, 32, 5, 64, 18, 7, 37, 48}) = 6 should be the correct answer count = 0; for (i = 1; i <= 10; i++){ if ((A[i] & 3) == 0) // test whether the two rightmost bits are ones count++; } 1 See Appendix to know more about an obvious and clear link.

a) (5 points) Is this algorithm correct? (Answer only Yes or No) b) (10 points) Whatever is your answer, prove it using the fastest method: a counterexample, a proof by contradiction, or a proof by inductio

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!