Verityprep
Question Bank · Unit 4

AP® Computer Science Principles Algorithms and Programming Practice Questions

Work through AP Computer Science Principles practice questions on Algorithms and Programming, then check each answer against a worked solution.

Free · no sign-up Open questions need no account. Sign up or log in to open the rest.

Subtopic: Algorithms Clear filter

Questions 1–10 of 49
  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10

Question 1

Multiple choice Algorithms

The question below uses a robot in a grid of squares. The robot is represented as a triangle, which is initially in the bottom left square of the grid and facing right.

Figure

The following programs are each intended to move the robot to the gray square. Program II uses the procedure GoalReached, which returns true if the robot is in the gray square and returns false otherwise.

Figure

Which of the following statements best describes the correctness of the programs?

Pick an answer, then check it. The solution opens in a window.

Question 2

Multiple choice Algorithms
Which of the following actions are generally helpful in program development? I. Consulting potential users of the program to identify their concerns…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 3

Multiple choice Algorithms
The following algorithm is intended to take a positive integer as input and display its individual digits in order from right to left. For example, if the input…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 4

Multiple choice Algorithms

The grid below contains a robot represented as a triangle, initially facing right. The robot can move into a white or gray square but cannot move into a black region.

Figure

The code segment below uses the procedure GoalReached, which evaluates to true if the robot is in the gray square and evaluates to false otherwise.

REPEAT UNTIL (GoalReached ())
{
    <MISSING CODE>
}

Which of the following replacements for <MISSING CODE> can be used to move the robot to the gray square?

Pick an answer, then check it. The solution opens in a window.

Question 5

Multiple choice Algorithms
Which of the following best explains why it is not…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 6

Multiple choice Algorithms
The following question uses a robot in a grid of squares. The robot is represented by a triangle, which is initially facing toward the top of the…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 7

Multiple choice Algorithms
A photographer has a collection of digital pictures, each using the same file-naming format: a date tag, followed by a description, followed by the file…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 8

Multiple choice Algorithms
Consider the following algorithms. Each algorithm operates on a list containing n elements, where n is a very large integer. I. An algorithm that accesses each…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 9

Multiple choice Algorithms
The following algorithm is intended to determine the average height, in centimeters, of a group of people in a room. Each person has a card, a pencil, and an…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 10

Multiple choice Algorithms
A movie theater charges $12 for a regular ticket and $9 for children aged 12 or younger and seniors aged 60 or older. A 3-D movie costs an additional $5. age is…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 1 of 49
Page 1 of 5