Search Header Logo

3.9 Developing Algorithms

Authored by MYKAELA ALFRED

Other

12th Grade

Used 3+ times

 3.9 Developing Algorithms
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

8 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

3 mins • 3 pts

Media Image

Consider the following code segment with an integer variable num. IF(num > 0) { DISPLAY("positive") } IF(num < 0) { DISPLAY("negative") } IF(num = 0) { DISPLAY("zero") } Which of the following code segments is equivalent to the code segment above?

IF(num < 0) { DISPLAY("negative") } ELSE { DISPLAY("positive") } IF(num = 0) { DISPLAY("zero") }

IF(num < 0) { DISPLAY("negative") } ELSE { IF(num = 0) { DISPLAY("zero") } ELSE { DISPLAY("positive") } }

IF(num ≤ 0) { DISPLAY("negative") } ELSE { IF(num = 0) { DISPLAY("zero") } ELSE { DISPLAY("positive") } }

IF(num ≤ 0) { DISPLAY("negative") } IF(num = 0) { DISPLAY("zero") } ELSE { DISPLAY("positive") }

2.

MULTIPLE CHOICE QUESTION

3 mins • 5 pts

Media Image

Inserting the statement count ← count + 1 between line 6 and line 7

Inserting the statement count ← count + 2 between line 6 and line 7

Inserting the statement count ← count + 1 between line 8 and line 9

Inserting the statement count ← count + n between line 8 and line 9

3.

MULTIPLE CHOICE QUESTION

3 mins • 2 pts

Media Image

Consider the following program. The variable x is set to 2, then a loop that repeats 4 times updates x using x ← x * 3. Which of the following expressions represents the value stored in the variable x as a result of executing the program?

4.

MULTIPLE CHOICE QUESTION

3 mins • 5 pts

Media Image

A student is creating a procedure to determine whether the weather for a particular month was considered very hot. The procedure takes as input a list containing daily high temperatures for a particular month and is intended to return true if the daily high temperature was at least 90 degrees for a majority of days in the month and return false otherwise. PROCEDURE IsHot (temperatureList) { total <- 0 counter <- 0 FOR EACH temperature IN temperatureList { IF (temperature >= 90) { counter <- counter + 1 } total <- total + 1 } RETURN () } Which of the following can be used to replace so that the procedure works as intended?

counter < 0.5 * total

counter > 0.5 * total

total < 0.5 * counter

total > 0.5 * counter

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Media Image

Programs I and II below are each intended to calculate the sum of the integers from 1 to n. Assume that n is a positive integer (e.g., 1, 2, 3, ...). Which of the following best describes the behavior of the two programs?

Program I displays the correct sum, but program II does not.

Program II displays the correct sum, but program I does not.

Both program I and program II display the correct sum.

Neither program I nor program II displays the correct sum.

6.

MULTIPLE CHOICE QUESTION

3 mins • 3 pts

Media Image

Consider the two programs below. Program A: i ← 1; REPEAT UNTIL (i > 10): DISPLAY i; i ← i + 1. Program B: i ← 1; REPEAT UNTIL (i > 10): i ← i + 1; DISPLAY i. Which of the following best compares the values displayed by programs A and B?

Program A and program B display identical values.

Program A and program B display the same values in different orders.

Program A and program B display the same number of values, but the values differ.

Program A and program B display a different number of values.

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Media Image

Directions: The question or incomplete statement below is followed by four suggested answers or completions. Select the one that is best in each case. Consider the code segment below. Line 1: IF (a = 0) Line 2: { Line 3: b ← a + 10 Line 4: } Line 5: ELSE Line 6: { Line 7: b ← a + 20 Line 8: } Which of the following changes will NOT affect the results when the code segment is executed?

Changing line 3 to b ← 10

Changing line 3 to a ← b + 10

Changing line 7 to b ← 20

Changing line 7 to a ← b + 20

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?