Gce Model Questions Vol1 2025 Computer Studies Question 48

Practice objective / multiple choice question 48 from the 2025 Gce Model Questions Vol1 Computer Studies examination.

Gce Model Questions Vol1 2025 Computer Studies Objective / Multiple Choice Hard Difficulty
Question 48 GCE_MODEL_QUESTIONS_VOL1 • 2025 • COMPUTER_STUDIES • objective

A staircase has n steps. You may climb either 1 step or 2 steps at a time, but you are never allowed to take two consecutive 2‑step moves. The following Python function implements a dynamic‑programming solution: ```python def count_ways(n): A = [0]*(n+1) # ways ending with a 1‑step B = [0]*(n+1) # ways ending with a 2‑step (preceded by a 1‑step) if n >= 1: A[1] = 1 if n >= 2: A[2] = 1 B[2] = 1 for i in range(3, n+1): A[i] = A[i-1] + B[i-1] B[i] = A[i-2] return A[n] + B[n] print(count_ways(6)) ``` What integer does the program output for n = 6?

Answer Options

A. 8
Correct Answer B. 9
C. 12
D. 10
Correct Answer
B
Correct Option:
9

About This Question

This is Gce Model Questions Vol1 2025 Computer Studies Question 48. It is one of the objective questions from the 2025 Gce Model Questions Vol1 Computer Studies examination.

Difficulty level: Hard .

Master the Exam!

You've seen a preview, but there are thousands more questions plus AI tutor to break down complex solutions.

Unlock Full Access Available for Android & Windows
Chat with Support