Photo AI

Figure 2 shows an algorithm that uses integer division which has been represented using pseudo-code - AQA - GCSE Computer Science - Question 2 - 2023 - Paper 1

Question icon

Question 2

Figure-2-shows-an-algorithm-that-uses-integer-division-which-has-been-represented-using-pseudo-code-AQA-GCSE Computer Science-Question 2-2023-Paper 1.png

Figure 2 shows an algorithm that uses integer division which has been represented using pseudo-code. - Line numbers are included but are not part of the algorithm. ... show full transcript

Worked Solution & Example Answer:Figure 2 shows an algorithm that uses integer division which has been represented using pseudo-code - AQA - GCSE Computer Science - Question 2 - 2023 - Paper 1

Step 1

Where is iteration first used in the algorithm in Figure 2?

96%

114 rated

Answer

Iteration is first used in the algorithm at Line number 6 where the inner WHILE loop begins, checking the condition a > 0.

Step 2

In the algorithm in Figure 2, what will be output when the user input is 10?

99%

104 rated

Answer

When the user inputs 10, the algorithm divides 10 by 3 iteratively. The value of a will change as follows:

  • 10 DIV 3 = 3
  • 3 DIV 3 = 1
  • 1 DIV 3 = 0

The final output will be 1.

Step 3

In the algorithm in Figure 2, what is the largest possible value of the variable counter when the user input is 36?

96%

101 rated

Answer

The largest value of counter occurs when we start from 36:

  1. 36 DIV 3 = 12
  2. 12 DIV 3 = 4
  3. 4 DIV 3 = 1
  4. 1 DIV 3 = 0

Thus, counting the iterations:

  • From 36 to 12 (1)
  • From 12 to 4 (2)
  • From 4 to 1 (3)
  • From 1 to 0 (4)

This means the largest possible value of counter is 4.

Join the GCSE students using SimpleStudy...

97% of Students

Report Improved Results

98% of Students

Recommend to friends

100,000+

Students Supported

1 Million+

Questions answered

;