uiz Space

May 2022 term · Computational Thinking · BSCS1001

Computational Thinking Qualifier: 7 August 2022 (May 2022 term)

The IIT Madras BS Computational Thinking (Computational Thinking (CT)) Qualifier paper sat on 7 Aug 2022, in the May 2022 term: 14 questions for 50 marks in 120 minutes. Every question is below with its answer. Take it as a timed mock test to be marked, or read it through first.

Questions
14
Marks
50
Duration
120 min
MCQ
10
MSQ
4

Updated

Official paper: IIT M QUALIFIER EXAM QPE 07 Aug 2022 IBA NS · No negative marking.

Question 1

+3 marksOne correct option

The following pseudocode is executed using the "Words" dataset. What will A represent at the end of execution?

text
A = 0
while (Table 1 has more rows) {
Read the first row X in Table 1
if (X.PartOfSpeech == “Noun” and X.LetterCount > 6) {
A = A + 1
}
Move X to Table 2
}
  1. A

    Number of words which have more than 6 letters

  2. B

    Number of nouns which have more than 6 letters

  3. C

    Number of nouns which have less than 6 letters

  4. D

    Number of words which have less than 6 letters

Show answer

Correct answer

  • B

    Number of nouns which have more than 6 letters

Question 2

+3 marksOne correct option

The following pseudocode is executed using the "Olympics" dataset. Assume that no player won more than one medal. What will A represent at the end of execution?

text
A = 0
while (Pile 1 has more cards) {
Read the first row X in Table 1
Move X to Pile 2
while (Pile 1 has more cards) {
Read the first row Y in Table 1
Move Y to Pile 3
if (X.Nationality == Y.Nationality and X.Gender ≠ Y.Gender) {
A = A + 1
}
}
Move all cards from Pile 3 to Pile 1
}
  1. A

    Number of pairs of players having different nationality but same gender

  2. B

    Number of pairs of players having either same nationality or same gender

  3. C

    Number of pairs of players having same nationality but different gender

  4. D

    Number of pairs of players having same nationality and same gender

Show answer

Correct answer

  • C

    Number of pairs of players having same nationality but different gender

Question 3

+3 marksOne or more correct options

The following pseudocode is executed using the "Scores" dataset. What will Count represent at the end of execution? It is a Multiple Select Question (MSQ).

text
Count = 0
while (Table 1 has more rows) {
Read the first row X in Table 1
Move X to Table 2
if (X.Mathematics == X.Physics or X.Gender ==‘M’) {
Count = Count + 1
}
}

Select all that apply.

  1. A

    Number of male students whose Mathematics and Physics marks are same

  2. B

    Number of male students + Number of students whose Mathematics and Physics marks are same

  3. C

    Number of male students + Number of female students whose Mathematics and Physics marks are same

  4. D

    Number of students whose Mathematics and Physics marks are same + Number of male students whose Mathematics and Physics marks are not same

Show answer

Correct answers

  • C

    Number of male students + Number of female students whose Mathematics and Physics marks are same

  • D

    Number of students whose Mathematics and Physics marks are same + Number of male students whose Mathematics and Physics marks are not same

Question 4

+3 marksOne or more correct options

The following pseudocode is executed using the "Olympics" dataset. Count represents the number of pairs of distinct players who won the same medal but not in the same sport. Assume that no player won more than one medal. Choose the correct code fragment to complete the pseudocode. It is a Multiple Select Question (MSQ).

text
Count = 0
while (Table 1 has more rows) {
Read the first row X in Table 1
Move X to Table 2
while (Table 1 has more rows) {
Read the first row Y in Table 1
Move Y to Table 3
********************
* Fill the code *
********************
}
Move all rows from Table 3 to Table 1
}

Select all that apply.

  1. A
  2. B
  3. C
  4. D
Show answer

Correct answers

  • B
  • C
  • D

Question 5

+2 marksOne correct option

The following pseudocode is executed using the "Words" dataset.

text
CountA = 0, CountB = 0
while (Table 1 has more rows) {
Read the first row X in Table 1
i = X.LetterCount
A = first letter of X.Word
B = iᵗʰ letter of X.Word
if (A == B) {
if (B is a vowel) {
CountA = CountA + 1
}
CountB = CountB + 1
}
Move X to Table 2
}

Based on the above data, answer the given subquestions.

What will CountB represent at the end of execution?

  1. A

    Number of duplicate words

  2. B

    Number of words which start and end with vowels

  3. C

    Number of words which start and end with the same vowel

  4. D

    Number of words which start and end with the same letter

Show answer

Correct answer

  • D

    Number of words which start and end with the same letter

Question 6

+2 marksOne correct option

The following pseudocode is executed using the "Words" dataset.

text
CountA = 0, CountB = 0
while (Table 1 has more rows) {
Read the first row X in Table 1
i = X.LetterCount
A = first letter of X.Word
B = iᵗʰ letter of X.Word
if (A == B) {
if (B is a vowel) {
CountA = CountA + 1
}
CountB = CountB + 1
}
Move X to Table 2
}

Based on the above data, answer the given subquestions.

What will CountA represent at the end of execution?

  1. A

    Number of duplicate words

  2. B

    Number of words which start and end with vowels

  3. C

    Number of words which start and end with the same vowel

  4. D

    Number of words which start and end with the same letter

Show answer

Correct answer

  • C

    Number of words which start and end with the same vowel

Question 7

+4 marksOne correct option

A palindrome is a sequence of characters which reads the same backward as forward, for example level and noon. The following pseudocode that counts palindromes is executed using the "Words" dataset. Choose the correct code fragment to complete the pseudocode.

text
A = 0
while (Table 1 has more rows) {
Read the first row X in Table 1
i = 1
j = X.LetterCount
Flag = True
while (i < j and Flag) {
********************
* Fill the code *
********************
i = i + 1
j = j - 1
}
if (Flag) {
A = A + 1
}
Move X to Table 2
}
  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • A

Question 8

+4 marksOne correct option

The following pseudocode is executed using the "Scores" dataset. What will Count represent at the end of execution?

text
Count = 0
while (Table 1 has more rows) {
Read the first row X in Table 1
Move the row X to Table 2
while (Table 1 has more rows) {
Read the first row Y in Table 1
Count = Count + compareSomething(X.Total, Y.Total)
Count = Count + compareSomething(Y.Total, X.Total)
Move the row Y to Table 3
}
Move all rows from Table 3 to Table 1
}
Procedure compareSomething(A, B)
if (A ≤ B) {
return (1)
}
else {
return (-1)
}
End compareSomething
  1. A

    It is always zero

  2. B

    Number of pairs of students who have different total marks

  3. C

    Number of pairs of students who have same total marks

  4. D

    Twice the number of pairs of students who have different total marks

  5. E

    Twice the number of pairs of students who have same total marks

Show answer

Correct answer

  • E

    Twice the number of pairs of students who have same total marks

Question 9

+4 marksOne correct option

The following pseudocode is executed using the "Scores" dataset. At the end of execution, B captures the minimum Mathematics marks of a student whose
(i) Total marks is more than the average total marks
(ii) Mathematics marks is more than Physics and Chemistry marks
Assume that the variable Avg holds the value of the average total marks. Choose the correct code fragment to complete the pseudocode.

text
while (Table 1 has more rows) {
Read the first row X in Table 1
********************
* Fill the code *
********************
}
B = 101
while (Table 3 has more rows) {
Read the first row X in Table 3
if (X.Total > Avg and X.Mathematics < B) {
B = X.Mathematics
}
Move X to Table 2
}
  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • A

Question 10

+4 marksOne correct option

The following pseudocode is executed using the "Words" dataset. What will A represent at the end of execution?

text
A = 0, B = 0, C = 0
while (Table 1 has more rows) {
Read the first row X in Table 1
Move X to Table 2
if (X.PartOfSpeech == “Adjective”) {
B = B + 1
}
if (X.PartOfSpeech == “Verb”) {
C = C + 1
}
if (X.Word ends with a full stop) {
if (B ≥ 1 and C ≤ 2) {
A = A + 1
}
B = 0, C = 0
}
}
  1. A

    Number of sentences with at most two adjectives and one verb

  2. B

    Number of sentences with two adjectives and at least one verb

  3. C

    Number of sentences with at least one verb and at most two adjectives

  4. D

    Number of sentences with at least one adjective and at most two verbs

Show answer

Correct answer

  • D

    Number of sentences with at least one adjective and at most two verbs

Question 11

+4 marksOne correct option

The following pseudocode is executed using the "Scores" dataset. What will A represent at the end of execution?

text
A = 0
while (Table 1 has more rows) {
Read the first row X in Table 1
Move X to Table 2
B = True
while (Table 1 has more rows) {
Read the first row Y in Table 1
if (X.Physics == Y.Physics) {
B = False
Move Y to Table 2
}
else {
Move Y to Table 3
}
}
if (B) {
A = A + 1
}
Move all rows from Table 3 to Table 1
}
  1. A

    Number of pairs of students who have the same Physics marks

  2. B

    Number of students with unique Physics marks

  3. C

    Number of students who do not have unique Physics marks

  4. D

    Twice the number of pairs of students who have the same Physics marks

Show answer

Correct answer

  • B

    Number of students with unique Physics marks

Question 12

+4 marksOne correct option

The following pseudocode is executed using the "Scores" dataset. What will (A - B) represent at the end of execution?

text
A = 0, B = 0
while (Pile 1 has more cards) {
Read the first row X in Table 1
Move X to Pile 2
while (Pile 1 has more cards) {
Read the first row Y in Table 1
Move Y to Pile 3
if (X.Gender == Y.Gender or X.CityTown == Y.CityTown) {
A = A + 1
}
if (X.Gender == Y.Gender and X.CityTown == Y.CityTown) {
B = B + 1
}
}
Move all cards from Pile 3 to Pile 1
}
  1. A

    Number of pairs of students having same gender but from different City/Town

  2. B

    Number of pairs of students having same gender and from same City/Town

  3. C

    Number of pairs of students having either same gender or from same City/Town but not both

  4. D

    Number of pairs of students having neither same gender nor from same City/Town

Show answer

Correct answer

  • C

    Number of pairs of students having either same gender or from same City/Town but not both

Question 13

+5 marksOne or more correct options

A sentence is said to be balanced if there are equal numbers of vowels and consonants in it. The following pseudocode is executed using the "Words" dataset. At the end of execution, Bcount counts the number of balanced sentences. But the pseudocode may have mistakes. Identify all such mistakes (if any). It is a Multiple Select Question (MSQ).

text
1 Bcount = 0
2 CountV = 0, CountC = 0
3 while (Table 1 has more rows) {
4 Read the first row X in Table 1
5 CountV, CountC = countSomething(X, CountV, CountC)
6 if (X.Word ends with a full stop) {
7 if (CountV ≠ CountC) {
8 Bcount = Bcount + 1
9 }
10 }
11 CountV = 0, CountC = 0
12 Move the row X to Table 2
13 }
14 Procedure countSomething(Y, A, B)
15 i = 0
16 while (i ≤ Y.LetterCount) {
17 if (ith letter of Y.Word is vowel) {
18 A = A + 1
19 }
20 else {
21 B = B + 1
22 }
23 i = i + 1
24 }
25 return ([A, B])
26 End countSomething

Select all that apply.

  1. A

    Line 2, incorrect initialization of CountV and CountC

  2. B

    Line 7, incorrect if condition

  3. C

    Line 8, invalid update of Bcount

  4. D

    Line 11, misplaced re-initialization of CountV and CountC

  5. E

    Line 15, incorrect initialization of i

  6. F

    Line 21, incorrect increment of B

  7. G

    Line 25, incorrect return value

  8. H

    No error

Show answer

Correct answers

  • B

    Line 7, incorrect if condition

  • D

    Line 11, misplaced re-initialization of CountV and CountC

  • E

    Line 15, incorrect initialization of i

Question 14

+5 marksOne or more correct options

The following pseudocode is executed using the "Olympics" dataset. It counts the number of pairs of players who have the same medal but different nationality. Assume that no player has won more than one medal. But the pseudocode may have mistakes in one or more lines. Identify all such lines (if any). It is a Multiple Select Question (MSQ).

text
1 while (Table 1 has more rows) {
2 Read the first row X in Table 1
3 if (X.Medal == “Gold”) {
4 Move X to Table G
5 }
6 if (X.Medal == “Silver”) {
7 Move X to Table S
8 }
9 if (X.Medal == “Bronze”) {
10 Move X to Table B
11 }
12 }
13 count = common(Table G) + common(Table S) + common(Table B)
14 Procedure common(Table T1)
15 A = 1
16 while (Table T1 has more rows) {
17 Read the first row X in Table T1
18 Move X to Table T2
19 while (Table T2 has more rows) {
20 Read the first row Y in Table T1
21 Move Y to Table T3
22 if (X.Nationality == Y.Nationality) {
23 A = A + 1
24 }
25 }
26 Move all rows from Table T3 to Table T2
27 }
28 return(A)
29 End common

Select all that apply.

  1. A

    Line 3, incorrect if condition

  2. B

    Line 13, incorrect update of count

  3. C

    Line 15, incorrect initialization of A

  4. D

    Line 19, incorrect while condition

  5. E

    Line 22, incorrect if condition

  6. F

    Line 23, incorrect increment of A

  7. G

    Line 26, moved to incorrect table

Show answer

Correct answers

  • C

    Line 15, incorrect initialization of A

  • D

    Line 19, incorrect while condition

  • E

    Line 22, incorrect if condition

  • G

    Line 26, moved to incorrect table