uiz Space

May 2022 term · Computational Thinking · BSCS1001

Computational Thinking Qualifier: 10 July 2022 (May 2022 term)

The IIT Madras BS Computational Thinking (Computational Thinking (CT)) Qualifier paper sat on 10 Jul 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 QPA1 10 July 2022 · No negative marking.

Question 1

+2 marksOne correct option

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

text
1 A = 0
2 while(Table 1 has more rows){
3 Read the first row X in Table 1
4 i = 1, B = True
5 while(i <= X.LetterCount){
6 if(ith letter of X.Word is a vowel){
7 B = False
8 }
9 i = i + 1
10 }
11 if(B){
12 A = A + 1
13 }
14 Move X to Table 2
15 }
  1. A

    Number of words with at most one vowel

  2. B

    Number of words with exactly one vowel

  3. C

    Number of words with only vowels

  4. D

    Number of words without vowels

Show answer

Correct answer

  • D

    Number of words without vowels

Question 2

+2 marksOne correct option

The following pseudocode is executed using the "Words" dataset. At the end of the execution, A is set to True if there exist a pair of words with same part of speech and same letter count. Choose the correct code fragment to complete the pseudocode.

text
1 A = False
2 while(Table 1 has more rows){
3 Read the first row X in Table 1
4 Move X to Table 2
5 while(Table 1 has more rows){
6 Read the first row Y in Table 1
7 ********************
8 * Fill the code *
9 ********************
10 Move Y to Table 3
11 }
12 Move all rows from Table 3 to Table 1
13 }
  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • A

Question 3

+2 marksOne correct option

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

text
1 A = 0, count = 0
2 while(Table 1 has more rows){
3 Read the first row X in Table 1
4 if(X.Year > A){
5 A = X.Year
6 }
7 Move X to Table 2
8 }
9 while(Table 2 has more rows){
10 Read the first row Y in Table 2
11 if(Y.Year != A){
12 count = count + 1
13 }
14 Move Y to Table 1
15 }
  1. A

    Number of authors who have not published a book in the most recent year

  2. B

    Number of authors who have not published maximum number of books

  3. C

    Number of books which are not published in the most recent year

  4. D

    Number of authors who have published a book in the most recent year

Show answer

Correct answer

  • C

    Number of books which are not published in the most recent year

Question 4

+3 marksOne correct option

Let A be an author who has written a book in the "Library" dataset and B be a positive integer. What does the procedure DoSomething compute?

text
1 Procedure DoSomething(A, B)
2 C = 0, D = 2023
3 while(Table 1 has more rows){
4 Read the first row X in Table 1
5 if(X.Author == A){
6 if(X.Year > C){
7 C = X.Year
8 }
9 if(X.Year < D){
10 D = X.Year
11 }
12 }
13 Move X to Table 2
14 }
15 if(C - D >= B){
16 return(True)
17 }
18 else{
19 return(False)
20 }
21 End DoSomething
  1. A

    Outputs True if the second book of author A was published at least B years after his/her first book

  2. B

    Outputs True if the last book of author A was published at least B years after his/her first book

  3. C

    Outputs True if the last book of author A was published at least B years after his/her second last book

  4. D

    None of these

Show answer

Correct answer

  • B

    Outputs True if the last book of author A was published at least B years after his/her first book

Question 5

+3 marksOne correct option

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

text
1 count = 0
2 while(Table 1 has more rows){
3 Read the first row X from Table 1
4 count = count + checkSomething(X)
5 Move X to Table 2
6 }
7 Procedure checkSomething(Z)
8 i = Z.LetterCount
9 while(i > 0){
10 if(ith letter of Z.Word is vowel){
11 return(0)
12 }
13 i = i - 1
14 }
15 return(1)
16 End checkSomething
  1. A

    Number of vowels

  2. B

    Number of words that have only vowels

  3. C

    Number of words that have only consonants

  4. D

    Number of words that have both vowels and consonants

  5. E

    None of these

Show answer

Correct answer

  • C

    Number of words that have only consonants

Question 6

+4 marksOne correct option

miniSum accepts three distinct numbers as parameters and returns the sum of two smallest numbers. Choose the correct code fragment to complete the procedure.

text
1 Procedure miniSum(A, B, C)
2 Sum = 0
3 if(A > C and A > B){
4 Sum = B + C
5 }
6 ********************
7 * Fill the code *
8 ********************
9 return(Sum)
10 End miniSum
  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • D

Question 7

+4 marksOne correct option

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

text
1 count = 0
2 while(Table 1 has more rows){
3 Read the first row X from Table 1
4 Move X to Table 2
5 Flag = True
6 if(X.Genre != "Fiction"){
7 Flag = False
8 }
9 if(Flag){
10 while(Table 1 has more rows){
11 Read the first row Y from Table 1
12 if(X.Author == Y.Author){
13 Move Y to Table 2
14 if(Y.Genre != "Fiction"){
15 Flag = False
16 }
17 }
18 else{
19 Move Y to Table 3
20 }
21 }
22 Move all rows from Table 3 to Table 1
23 }
24 if(Flag){
25 count = count + 1
26 }
27 }
  1. A

    Number of authors who have written exactly one book under genre "Fiction"

  2. B

    Number of pairs of authors who have not written any book under genre "Fiction"

  3. C

    Number of authors who have written books only under genre "Fiction"

  4. D

    Number of pairs of authors who have written books only under genre "Fiction"

Show answer

Correct answer

  • C

    Number of authors who have written books only under genre "Fiction"

Question 8

+3 marksOne or more correct options

The following pseudocode is executed using the "Words" dataset. At the end of the execution, C captures the number of nouns with letter count at least four and at most eight. But the pseudocode may have mistakes. Identify all such mistakes (if any). Assume that all statements not listed in the options below are free of errors. It is a Multiple Select Question (MSQ).

text
1 C = 0
2 while(Table 1 has more rows){
3 Read the first row X from Table 1
4 if(CheckSomething(X, 4, 8)){
5 C = C + 1
6 }
7 Move X to Table 2
8 }
9 Procedure CheckSomething(Y, C1, C2)
10 if(Y.PartOfSpeech == "Noun"){
11 if(C1 <= Y.LetterCount and Y.LetterCount <= C2){
12 return(True)
13 }
14 else{
15 return(False)
16 }
17 }
18 else{
19 return(False)
20 }
21 End CheckSomething

Select all that apply.

  1. A

    Error in Line 1

  2. B

    Error in Line 4

  3. C

    Error in Line 5

  4. D

    Error in Line 10

  5. E

    Error in Line 11

  6. F

    Multiple return(False) in procedure CheckSomething

  7. G

    No error

Show answer

Correct answer

  • G

    No error

Question 9

+5 marksOne correct option

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

text
1 count = 0
2 while(Table 1 has more rows){
3 Read the first row X in Table 1
4 Move X to Table 2
5 while(Table 1 has more rows){
6 Read the first row Y from Table 1
7 count = count + isSimilar(X, Y)
8 Move Y to Table 3
9 }
10 Move all rows from Table 3 to Table 1
11 }
12 Procedure isSimilar(A, B)
13 if(A.LetterCount != B.LetterCount){
14 return (0)
15 }
16 i = 1
17 while(i <= A.LetterCount){
18 if(ith letter of A.Word is vowel and ith letter of B.Word is vowel){
19 return(0)
20 }
21 if(ith letter of A.Word is consonant and ith letter of B.Word is consonant){
22 return(0)
23 }
24 i = i + 1
25 }
26 return(1)
27 End isSimilar
  1. A

    Number of pairs of words with different letter count and the position of vowels and consonants in both words are same

  2. B

    Number of pairs of words with same letter count and the position of vowels and consonants in both words are same

  3. C

    Number of pairs of words with same letter count + Number of pairs of words where the position of vowels and consonants in both words are interchanged

  4. D

    Number of pairs of words with same letter count and the position of vowels and consonants in both words are interchanged

Show answer

Correct answer

  • D

    Number of pairs of words with same letter count and the position of vowels and consonants in both words are interchanged

Question 10

+5 marksOne or more correct options

The following pseudocode is executed using the "Words" dataset. At the end of the execution, A captures the number of sentences with at least two nouns that have at most 2 vowels. The pseudocode may have mistakes. Identify all such mistakes (if any). Assume that all statements not listed in the options below are free of errors. It is a Multiple Select Question (MSQ).

text
1 A = 0, C = 0
2 while(Table 1 has more rows){
3 Read the first row X from Table 1
4 if(X.PartOfSpeech == "Noun" and CountVowels(X) <= 2){
5 C = C + 1
6 }
7 if(X.Word ends with a full stop){
8 if (C >= 2){
9 A = A + 1
10 C = 0
11 }
12 }
13 Move X to Table 2
14 }
15 Procedure CountVowels(Y)
16 i = 1, B = 0
17 while(i <= Y.LetterCount){
18 if(ith letter of Y.Word is a vowel){
19 B = B + 1
20 i = i + 1
21 }
22 }
23 return(B)
24 End CountVowels

Select all that apply.

  1. A

    Line 5: Error in updating C

  2. B

    Line 9: A is updated at a wrong place

  3. C

    Line 10: C is updated at a wrong place

  4. D

    Line 19: B is updated at a wrong place

  5. E

    Line 20: i is updated at a wrong place

  6. F

    Line 23: Return value is incorrect

  7. G

    No error

Show answer

Correct answers

  • C

    Line 10: C is updated at a wrong place

  • E

    Line 20: i is updated at a wrong place

Question 11

+5 marksOne or more correct options

The following pseudocode is executed using the "Library" dataset. At the end of the execution, A captures the number of pairs of books that are released in the same year and under the same genre but in different languages. The pseudocode may have mistakes. Identify all such mistakes (if any). Assume that all statements not listed in the options below are free of errors. It is a Multiple Select Question (MSQ).

text
1 A = 0
2 while(Table 1 has more rows){
3 Read the first row X from Table 1
4 Move X to Table 2
5 while(Table 1 has more rows){
6 Read the first row Y from Table 1
7 B = False, C = False, D = True
8 if(X.Genre == Y.Genre){
9 B = True
10 }
11 if(X.Year == Y.Year){
12 C = False
13 }
14 if(X.Language == Y.Language){
15 D = False
16 }
17 if(B or C or D){
18 A = A + 1
19 }
20 Move Y to Table 3
21 }
22 Move all rows from Table 3 to Table 1
23 }

Select all that apply.

  1. A

    Line 1: A is initialized with wrong value

  2. B

    Line 9: B is updated with wrong value

  3. C

    Line 12: C is updated with wrong value

  4. D

    Line 15: D is updated with wrong value

  5. E

    Line 17: Error in if-condition

  6. F

    No error

Show answer

Correct answers

  • C

    Line 12: C is updated with wrong value

  • E

    Line 17: Error in if-condition

Question 12

+5 marksOne or more correct options

The following pseudocode is executed using the "Scores" dataset. At the end of the execution, C captures the number of pairs of students who have same date of birth, or the same City/Town but different gender. Choose the correct code fragment(s) to complete the pseudocode. It is a Multiple Select Question

text
1 C = 0
2 while(Table 1 has more rows){
3 Read the first row X in Table 1
4 Move X to Table 2
5 while(Table 1 has more rows){
6 Read the first row Y in Table 1
7 ********************
8 * Fill the code *
9 ********************
10 Move Y to Table 3
11 }
12 Move all rows from Table 3 to Table 1
13 }

Select all that apply.

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

Correct answers

  • B
  • D

Question 13

+4 marksOne correct option

The following pseudocode is executed using the "Library" dataset. Assume that every author has published at least two books, and only one in a year.

text
1 Count = 0, c = 0, Diff = 0
2 while(Table 1 has more rows){
3 Read the first row X from Table 1
4 Move the row X to Table 2
5 while(Table 1 has more rows){
6 Read the first row Y from Table 1
7 if(X.Author == Y.Author){
8 Move the row Y to Table 2
9 }
10 else{
11 Move the row Y to Table 3
12 }
13 }
14 Diff = doSomething(Table 2)
15 if(Diff == c){
16 Count = Count + 1
17 }
18 if(Diff > c){
19 c = Diff
20 Count = 1
21 }
22 Delete all the rows from Table 2
23 Move all the rows from Table 3 to Table 1
24 }
25 Procedure doSomething(Table 2)
26 A = 0, B = 0
27 while(Table 2 has more rows){
28 Read the first row Z from Table 2
29 if(Z.Year > A){
30 B = A
31 A = Z.Year
32 }
33 if(Z.Year < A and Z.Year > B){
34 B = Z.Year
35 }
36 Move the row Z to Table 4
37 }
38 return(A - B)
39 End doSomething

Based on the above data, answer the given subquestions.

What will procedure doSomething return?

  1. A

    Difference between year of publication of first and second book of the same author

  2. B

    Difference between year of publication of first and second book of authors

  3. C

    Difference between year of publication of latest and second latest book of the same author

  4. D

    Difference between year of publication of first and latest book of authors

Show answer

Correct answer

  • C

    Difference between year of publication of latest and second latest book of the same author

Question 14

+3 marksOne correct option

The following pseudocode is executed using the "Library" dataset. Assume that every author has published at least two books, and only one in a year.

text
1 Count = 0, c = 0, Diff = 0
2 while(Table 1 has more rows){
3 Read the first row X from Table 1
4 Move the row X to Table 2
5 while(Table 1 has more rows){
6 Read the first row Y from Table 1
7 if(X.Author == Y.Author){
8 Move the row Y to Table 2
9 }
10 else{
11 Move the row Y to Table 3
12 }
13 }
14 Diff = doSomething(Table 2)
15 if(Diff == c){
16 Count = Count + 1
17 }
18 if(Diff > c){
19 c = Diff
20 Count = 1
21 }
22 Delete all the rows from Table 2
23 Move all the rows from Table 3 to Table 1
24 }
25 Procedure doSomething(Table 2)
26 A = 0, B = 0
27 while(Table 2 has more rows){
28 Read the first row Z from Table 2
29 if(Z.Year > A){
30 B = A
31 A = Z.Year
32 }
33 if(Z.Year < A and Z.Year > B){
34 B = Z.Year
35 }
36 Move the row Z to Table 4
37 }
38 return(A - B)
39 End doSomething

Based on the above data, answer the given subquestions.

What will Count represent at the end of the execution?

  1. A

    Number of authors with maximum gap between year of publication of their first and second book

  2. B

    Number of authors with minimum gap between year of publication of their first and second book

  3. C

    Number of authors with maximum gap between year of publication of their latest and second latest book

  4. D

    Number of authors with minimum gap between year of publication of their latest and second latest book

Show answer

Correct answer

  • C

    Number of authors with maximum gap between year of publication of their latest and second latest book