Quiz Space

Computational Thinking (CT) week 4 important questions

Week 4 of Computational Thinking: Nested iterations, birthday paradox, binning. Extra important questions based on the recent, changing patterns of the exams, from basic to advanced. Practise them in learning mode: each question has a worked solution.

Question 1

Numerical answer

The "Scores" table has the rows below (rows are numbered from 1 at the top).

NoNameCityMaths
1JayKochi88
2ChitraChennai71
3KavyaKochi91
4LakshmanChennai51
5IshaPune75
6GitaChennai87

Here n = 6 and T[k] is the k-th row. The following pseudocode is executed.

count = 0
i = 1
while (i <= n - 1) {
j = i + 1
while (j <= n) {
if (T[i].City == T[j].City) { count = count + 1 }
j = j + 1
}
i = i + 1
}
Print count

What is printed?

Question 2

One correct option

The "Scores" table has the rows below (rows are numbered from 1 at the top).

NoNameCityMaths
1ChitraJaipur51
2IshaChennai84
3KavyaPune45
4OmkarChennai78
5EshaDelhi89

Here n = 5 and T[k] is the k-th row. The following pseudocode is executed.

count = 0
i = 1
while (i <= n - 1) {
j = i + 1
while (j <= n) {
if (T[i].Maths > T[j].Maths) { count = count + 1 }
j = j + 1
}
i = i + 1
}
Print count

What is printed?

  1. A

    22

  2. B

    44

  3. C

    66

  4. D

    33

Question 3

Numerical answer

The "Scores" table has the rows below (rows are numbered from 1 at the top).

NoNameCityMaths
1FaridJaipur38
2ChitraChennai74
3IshaDelhi51
4GitaJaipur85
5PriyaKochi88

Here n = 5 and T[k] is the k-th row. The following pseudocode is executed.

count = 0
i = 1
while (i <= n - 1) {
j = i + 1
while (j <= n) {
if (T[i].Maths + T[j].Maths > 120) { count = count + 1 }
j = j + 1
}
i = i + 1
}
Print count

What is printed?

More questions in this week

Authorise with Google to see every question with its answer and explanation and practise it in learning mode.