MC Quiz 2
- Missed Questions:
- 34) A sorted list of numbers contains 500 elements. Which of the following is closest to the maximum number of list elements that will be examined when performing a binary search for a value in the list?
- 41) In a certain district, 20 percent of the voters are expected to vote for Candidate A in an election. The computer program below is intended to simulate the result of the election with n voters, and display the number of votes received by Candidate A.
Missed Questions:
34) A sorted list of numbers contains 500 elements. Which of the following is closest to the maximum number of list elements that will be examined when performing a binary search for a value in the list?
Correct Answer: 10 The binary representation of the number 500 is 9 bits. That means only 10 bits are needed to be examined
41) In a certain district, 20 percent of the voters are expected to vote for Candidate A in an election. The computer program below is intended to simulate the result of the election with n voters, and display the number of votes received by Candidate A.
Line 1: sum <-- 0
Line 2: REPEAT n TIMES:
Line 3: {
Line 4: IF (<MISSING CONDITION>)
Line 5: {
Line 6: sum <-- sum + 1
Line 7: }
Line 8: }
Line 9: DISPLAY (sum)
Correct Answer: I got A correct.. D) RANDOM (1, 10) <= 2
D is correct because the chance of getting the two numbers that satisfy this condition (1 and 2) is 20%
#### Which of the following statements is true?
Correct Answer: There exist problems that no algorithm will ever be able to solve for all possible inputs. Example: Determining problems which loop forever