AP Computer Science Unit 2 Review
(Edhesive)
A arithmetic professor at Howard University wants his students to jot down a application to solve
complicated mathematical problems. The professor asks a programmer to decide the
performance of each pupil's set of rules. How can the programmer decide the performance of
an algorithm?
Select two. - ANS-Run the program with many specific inputs to decide how a lot CPU time
might be required for algorithm to solve the trouble for inputs of different sizes.
AND
Use mathematical calculations to decide how the range of computations carried out by using
this system will increase as the size of the inputs boom.
A program has been advanced to compute the sum of all factors with a fee extra than 10 in a
listing of integers. Which of the following statements fine describes how iteration may be used
to in the software in this example? - ANS-The program will repeat the execution of a block of
instructions which check the fee of an object and add it to a strolling general (if it's far more than
10) for every price within the listing.
Each of the 52 cards in a trendy deck of gambling playing cards belongs to one of the 4 fits:
SPADES, HEARTS, CLUBS, or DIAMONDS. There are thirteen cards in a healthy, and the
values for every fit are as follows: ace, two, three, four, 5, six, seven, eight, 9, ten, jack, queen,
and king. Take into consideration the 2 algorithms indexed underneath, which can be designed
to locate and distinguish the card that represents the "TEN of HEARTS" from the opposite fifty
one cards in a deck that has been shuffled at random. A Algorithm Step 1: Take the shuffled
deck of playing cards and pick it up. Step 2: Look at the topmost card in your hands.
Step 3: If the cardboard's healthy is a HEART, vicinity the card on pinnacle of the pile in your
left.
Step four: If now not, region the card to your right on pinnacle of the pile. Step 5: Keep going
thru steps 2 through four till you not have any playing cards to your hand. Step 6: Select the
left-hand pile of cards. Step 7: Look on the topmost card in your arms.
Step eight: If the cardboard's price is a TEN, - ANS-Only Algorithm A will constantly paintings
as supposed.
A examine of beech timber shows that round 40% of these timber may be at risk of a newly
observed disorder. The pc application underneath is intended to decide the number of bushes
which may be prone to the ailment in a woodland containing k beech timber:
Line 1: general ← 1
Line 2: repeat okay times
Line 3:
Line 4: IF ()
Line five:
Line 6: total ← overall + 1
Line 7:
(Edhesive)
A arithmetic professor at Howard University wants his students to jot down a application to solve
complicated mathematical problems. The professor asks a programmer to decide the
performance of each pupil's set of rules. How can the programmer decide the performance of
an algorithm?
Select two. - ANS-Run the program with many specific inputs to decide how a lot CPU time
might be required for algorithm to solve the trouble for inputs of different sizes.
AND
Use mathematical calculations to decide how the range of computations carried out by using
this system will increase as the size of the inputs boom.
A program has been advanced to compute the sum of all factors with a fee extra than 10 in a
listing of integers. Which of the following statements fine describes how iteration may be used
to in the software in this example? - ANS-The program will repeat the execution of a block of
instructions which check the fee of an object and add it to a strolling general (if it's far more than
10) for every price within the listing.
Each of the 52 cards in a trendy deck of gambling playing cards belongs to one of the 4 fits:
SPADES, HEARTS, CLUBS, or DIAMONDS. There are thirteen cards in a healthy, and the
values for every fit are as follows: ace, two, three, four, 5, six, seven, eight, 9, ten, jack, queen,
and king. Take into consideration the 2 algorithms indexed underneath, which can be designed
to locate and distinguish the card that represents the "TEN of HEARTS" from the opposite fifty
one cards in a deck that has been shuffled at random. A Algorithm Step 1: Take the shuffled
deck of playing cards and pick it up. Step 2: Look at the topmost card in your hands.
Step 3: If the cardboard's healthy is a HEART, vicinity the card on pinnacle of the pile in your
left.
Step four: If now not, region the card to your right on pinnacle of the pile. Step 5: Keep going
thru steps 2 through four till you not have any playing cards to your hand. Step 6: Select the
left-hand pile of cards. Step 7: Look on the topmost card in your arms.
Step eight: If the cardboard's price is a TEN, - ANS-Only Algorithm A will constantly paintings
as supposed.
A examine of beech timber shows that round 40% of these timber may be at risk of a newly
observed disorder. The pc application underneath is intended to decide the number of bushes
which may be prone to the ailment in a woodland containing k beech timber:
Line 1: general ← 1
Line 2: repeat okay times
Line 3:
Line 4: IF ()
Line five:
Line 6: total ← overall + 1
Line 7: