City Guilds Model Questions Vol1 2017 Information Technology Question 39

Practice objective / multiple choice question 39 from the 2017 City Guilds Model Questions Vol1 Information Technology examination.

City Guilds Model Questions Vol1 2017 Information Technology Objective / Multiple Choice Hard Difficulty
Question 39 CITY_GUILDS_MODEL_QUESTIONS_VOL1 • 2017 • INFORMATION_TECHNOLOGY • objective

Consider the following pseudo‑code:\n\n``\ninteger n = input positive integer\ninteger count = 0\nfor i = 1 to n do\n for j = i to n do\n if (i + j) mod 3 = 0 then\n count = count + 1\n end if\n end for\nend for\noutput count\n```\n\n(a) What is the output when \(n = 6\)?\n(b) Derive a formula for \(count\) as a function of \(n\).\n(c) State the time‑complexity of the algorithm in Big‑O notation.\n(d) Propose an algorithm that computes the same \(count\) in \(O(n)\) time.

Answer Options

A. 7; count = c0*(c0+1)\/2 + c1*c2; O(n log n); O(1) algorithm using residue counts
B. 7; count = (c0+c1+c2)*(c0+c1+c2+1)\/2; O(n^2); O(1) algorithm using residue counts
Correct Answer C. 7; count = c0*(c0+1)/2 + c1*c2; O(n^2); O(1) algorithm using residue counts
D. 8; count = c0*(c0+1)\/2 + c1*c2; O(n^2); O(1) algorithm using residue counts
Correct Answer
C
Correct Option:
7; count = c0*(c0+1)/2 + c1*c2; O(n^2); O(1) algorithm using residue counts

About This Question

This is City Guilds Model Questions Vol1 2017 Information Technology Question 39. It is one of the objective questions from the 2017 City Guilds Model Questions Vol1 Information Technology 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