Quiz Space

May 2021 term · Computational Thinking · BSCS1001

Computational Thinking End Term: 8 August 2021 (May 2021 term)

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

Questions
25
Marks
50
Duration
180 min
MCQ
20
MSQ
5

Updated

Official paper: IIT M TERM FINAL EXAM POD21TEFNQP1 8 Aug 2021 · No negative marking.

Question 1

+1.5 marksOne correct option

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

text
A = 0, B = 0
while (Table 1 has more rows) {
Read the top row X from Table 1
if (X.Gender == 'M') {
A = A + 1
}
else {
if (X.Gender == 'M' or X.CityTown == "Chennai") {
B = B + 1
}
}
Move X to Table 2
}

What will B represent at the end of execution of pseudocode?

  1. A

    Number of Chennai Students

  2. B

    Number of female students from Chennai

  3. C

    Number of male students + Number of students from Chennai

  4. D

    Number of male students + Number of female students from Chennai

  5. E

    Number of students from Chennai + Number of male students who are not from Chennai

Show answer

Correct answer

  • B

    Number of female students from Chennai

Question 2

+1.5 marksOne correct option

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

text
A = False, B = False, count = 0
while (Table 1 has more rows) {
Read the first row X from Table 1
if (X.PartOfSpeech == "Pronoun") {
A = True
}
if (X.PartOfSpeech == "Noun") {
B = True
}
if (X.PartOfSpeech == "Adjective") {
if (A and B) {
count = count + 1
}
}
Move the row X to Table 2
}
  1. A

    Total number of adjectives

  2. B

    Number of adjectives before a noun and after a pronoun

  3. C

    Number of adjectives before a noun and a pronoun

  4. D

    Number of adjectives after both a noun and a pronoun have been seen

Show answer

Correct answer

  • D

    Number of adjectives after both a noun and a pronoun have been seen

Question 3

+2 marksOne correct option

The following pseudocode is executed using the "Library" dataset. What does (count−A+B) represent at the end of execution?

text
A = 0, B = 0, count = 0
while (Table 1 has more rows) {
Read the first row X from Table 1
if (X.Genre == "Fiction") {
A = A + 1
if (X.language == "English") {
B = B + 1
}
}
count = count + 1
Move the row X to Table 2
}
  1. A

    Total number of books.

  2. B

    Number of non fiction books

  3. C

    Number of non fiction books written other than in English

  4. D

    Number of non fiction books + Number of fiction books in English.

Show answer

Correct answer

  • D

    Number of non fiction books + Number of fiction books in English.

Question 4

+2 marksOne correct option

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

text
A = 0, B = 0, C = 0, D = 0
while (Table 1 has more rows) {
Read the top row X from Table 1
if (X.PhysicsMarks > X.ChemistryMarks) {
A = A + 1
}
else {
B = B + 1
}
if (X.PhysicsMarks < X.ChemistryMarks) {
C = C + 1
}
else {
D = D + 1
}
Move X to Table 2
}

What will (B + D) − (A + C) represent at the end of execution of pseudocode?

  1. A

    It is always zero

  2. B

    Number of students who have different marks in Physics and Chemistry

  3. C

    Number of students who have same marks in Physics and Chemistry

  4. D

    Twice the number of students who have different marks in Physics and Chemistry

  5. E

    Twice the number of students who have same marks in Physics and Chemistry

Show answer

Correct answer

  • E

    Twice the number of students who have same marks in Physics and Chemistry

Question 5

+2 marksOne correct option

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

text
D = { }, count = 0
while (Table 1 has more rows) {
Read the first row X from Table 1
if (isKey(D, X.Author)) {
D[X.Author] = D[X.Author] ++ [X.Name]
}
else {
D[X.Author] = [X.Name]
}
Move the row X to Table 2
}
foreach i in keys (D) {
if (length(D[i]) > 2) {
count = count +1
}
}
  1. A

    Number of pairs of authors who wrote more than two books.

  2. B

    Number of authors who wrote two books.

  3. C

    Number of pairs of authors who wrote more than one book.

  4. D

    Number of authors who wrote more than two books.

Show answer

Correct answer

  • D

    Number of authors who wrote more than two books.

Question 6

+2 marksOne correct option

The following pseudocode is executed using the "Scores" dataset. What does List store at the end of execution?

text
D = { }
List = [ ]
while (Table 1 has more rows) {
Read the first row X from Table 1
if (isKey(D, X.DateOfBirth)) {
D[X.DateOfBirth] = D[X.DateOfBirth] ++ [X.SeqNo]
}
else {
D[X.DateOfBirth] = [X.SeqNo]
}
Move the row X to Table 2
}
foreach i in keys(D) {
if (length(D[i]) > 1) {
List = List ++ D[i]
}
}
  1. A

    Sequence number of students who share date of birth with another student

  2. B

    Sequence number of students who do not share date of birth with another student

  3. C

    List of sequence number of students who share date of birth with another student

  4. D

    List of sequence number of students who do not share date of birth with another student

Show answer

Correct answer

  • C

    List of sequence number of students who share date of birth with another student

Question 7

+2 marksOne correct option

Consider the following pseudocode.

text
Procedure fib(n)
if (n ≤ 1) {
return (n)
}
return fib(n-1) + fib(n-2)
End fib

How many times will the procedure fib( ) be called if n = 5, excluding the main call?

  1. A

    8

  2. B

    10

  3. C

    14

  4. D

    12

Show answer

Correct answer

  • C

    14

Question 8

+2 marksOne correct option

Consider a matrix M generated from the "Words" dataset. If i and j represent two different words, when will M[i][j] be 1?

text
A = { }
while (Table 1 has more rows) {
Read the first row X from Table 1
A[X.SeqNo] = [X.PartOfSpeech, X.LetterCount]
Move the row X to Table 2
}
n = length(keys(A))
M = createMatrix (n, n)
foreach i in Keys (A) {
foreach j in Keys (A) {
if (i ≠ j and checkSomething(A[i], A[j])) {
M [i][j] = 1
}
}
}
Procedure checkSomething(word1, word2)
if (first(word1) == first(word2) and last(word1) ≠ last(word2)) {
return (True)
}
else {
return (False)
}
End checkSomething
  1. A

    If i and j have same part of speech but different letter count

  2. B

    If i and j have different part of speech but same letter count.

  3. C

    If i and j have same part of speech and same letter count.

  4. D

    If i and j have different part of speech and different letter count.

Show answer

Correct answer

  • A

    If i and j have same part of speech but different letter count

Question 9

+2.5 marksOne correct option

The following pseudocode is executed using the "Olympics" dataset. When will count2 be greater than count1?

text
D = { }
count1 = 0
count2 = 0
while (Table 1 has more rows) {
Read the first row X from Table 1
if (isKey(D, X.Name)) {
D[X.Name] = D[X.Name] + 1
}
else {
D[X.Name] = 1
}
Move the row X to Table 2
}
foreach k in keys(D) {
if (D[k] ≥ 5) {
count1 = count1+ 1
}
else {
count2 = count2+ 1
}
}
  1. A

    If the number of players who have won at most 5 medals is greater than the number of players who have won at least 5 medals.

  2. B

    If the number of players who have won less than 5 medals is greater than the number of players who have won at least 5 medals

  3. C

    If the number of players who have won at most 5 medals is lesser than the number of players who have won at least 5 medals.

  4. D

    If the number of players who have won at least 5 medals is greater than the number of players who have won at most 5 medals.

Show answer

Correct answer

  • B

    If the number of players who have won less than 5 medals is greater than the number of players who have won at least 5 medals

Question 10

+2.5 marksOne correct option

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

text
D = { }
while (Table 1 has more rows) {
Read the first row X from Table 1
if (isKey( D, X.Author )) {
if ( X.Year > D [X.Author]) {
D [X.Author] = X.Year
}
}
else {
D [X.Author] = X.Year
}
Move X to Table 2
}
A = 0, L = [ ]
foreach k in keys(D) {
if (D[k] == A) {
L = L ++ [k]
}
if (D[k] > A) {
A = D[k]
L = [k]
}
}
  1. A

    List of authors who published a book in the most recent year

  2. B

    List of authors who published maximum number of books in the most recent year

  3. C

    List of authors who published maximum number of books in a year

  4. D

    List of authors who published maximum number of books

  5. E

    None of these

Show answer

Correct answer

  • A

    List of authors who published a book in the most recent year

Question 11

+2.5 marksOne correct option

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

text
cityD = { }
while (Table 1 has more rows) {
Read the first row X in Table 1
if (isKey(cityD, X.CityTown)) {
cityD[X.CityTown] = cityD[X.CityTown] ++ [X.Total]
}
else {
cityD[X.CityTown] = [X.Total]
}
Move row X to Table 2
}
A = 0, B = [ ]
foreach i in keys(cityD) {
P = doSomething(cityD[i]) / length(cityD[i])
if (P == A) {
B = B ++ [i]
}
if (P > A) {
A = P
B = [i]
}
}
Procedure doSomething(L)
if (length(L) == 1) {
return(first(L))
}
else {
return(first(L) + doSomething(rest(L)))
}
End doSomething
  1. A

    List of students who got maximum total marks

  2. B

    List of cities with maximum total marks

  3. C

    List of cities with maximum average marks

  4. D

    List of cities with maximum average total marks

  5. E

    None of these

Show answer

Correct answer

  • D

    List of cities with maximum average total marks

Question 12

+2.5 marksOne correct option

The following table contains information regarding the books in "Library" dataset. Each entry in the table corresponds to an author and list of genre of books written by him. There is a pool of n authors, each author being assigned a unique author number between 0 and n−1.

Author.NoGenre List
0["Fiction", "Horror", "Fiction"]
......
n - 1["Fiction", "Fiction"]

The table is represented by a dictionary named D, with the keys as Author.No and values as the corresponding list GenreList. Assume that D has already been computed. For example, we have: D[0] = ["Fiction", "Horror", "Fiction"].

The following pseudocode generates a graph G from D. Each node corresponds to an author. Assume that each author has written at least one book. If i and j represents two different authors, when will M[i][j] be 1?

text
n = length(Keys(D))
M = createMatrix (n, n)
foreach i in keys (D) {
foreach j in keys (D) {
if (i ≠ j and seeSomething(D[i]) and seeSomething(D[j])) {
M[i][j] = 1
}
}
}
Procedure seeSomething(l)
Flag = True
D = { }
foreach i in l {
if (isKey(D, i)) {
D[i] = D[i] + 1
}
else {
D[i] = 1
}
}
foreach key in keys (D) {
if (D[key] > 1) {
Flag = False
}
}
return (Flag)
End seeSomething
  1. A

    If i has published multiple books of the same genre and j has published multiple books of the same genre.

  2. B

    If each book published by i is of a different genre and each book published by j is of a different genre.

  3. C

    If i has published multiple books of the same genre and each book published by j is of a different genre.

  4. D

    If each book published by i is of a different genre and j has published multiple books of the same genre.

  5. E

    None of these

Show answer

Correct answer

  • B

    If each book published by i is of a different genre and each book published by j is of a different genre.

Question 13

+2.5 marksOne correct option
  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • D

Question 14

+2 marksOne or more correct options

Consider the definition of the object datatype ClassList.

text
ClassList
private fields:
LValue, List
private procedures:
Procedure checkElements(n)
if (LValue < n) {
return(True)
}
else {
return(False)
}
End checkElements
public procedures:
Procedure initialize( )
LValue = 0
List = [ ]
End initialize
Procedure addElement(element)
if (checkElements(10)) {
LValue = LValue + 1
List = List ++ [element]
}
End addElement

Let cL be a ClassList object. Choose the correct statement(s) based on the definition of ClassList. It is a Multiple Select Question (MSQ).

Select all that apply.

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

Correct answers

  • A
  • D

Question 15

+1 markOne correct option

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

text
A = 0, B = 0, C = 0
P = False, Q = True
while (Table 1 has more rows) {
Read the first row X in Table 1
if (X.PartOfSpeech == "Adjective") {
C = C + X.LetterCount
P = True
}
if (P and X.PartOfSpeech == "Noun") {
B = B + X.LetterCount
}
if (Q) {
A = A + X.LetterCount
Q = False
}
else {
if (X.Word ends with a full stop) {
A = A + X.LetterCount
Q = True
P = False
}
}
Move X to Table 2
}

Based on the above data, answer the given subquestions.

What will C represent at the end of execution?

  1. A

    Total number of adjectives

  2. B

    Sum of letter count of all adjectives

  3. C

    Sum of letter count of all adjectives except the first of the dataset

  4. D

    Sum of letter count of all adjectives except the last of the dataset

Show answer

Correct answer

  • B

    Sum of letter count of all adjectives

Question 16

+2 marksOne correct option

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

text
A = 0, B = 0, C = 0
P = False, Q = True
while (Table 1 has more rows) {
Read the first row X in Table 1
if (X.PartOfSpeech == "Adjective") {
C = C + X.LetterCount
P = True
}
if (P and X.PartOfSpeech == "Noun") {
B = B + X.LetterCount
}
if (Q) {
A = A + X.LetterCount
Q = False
}
else {
if (X.Word ends with a full stop) {
A = A + X.LetterCount
Q = True
P = False
}
}
Move X to Table 2
}

Based on the above data, answer the given subquestions.

What will B represent at the end of execution?

  1. A

    Sum of letter count of all nouns which come after an adjective

  2. B

    Sum of letter count of all nouns which come next to an adjective

  3. C

    Sum of letter count of all the nouns that come after the first adjective in each sentence

  4. D

    Sum of letter count of all nouns which come next to the first adjective in each sentence

  5. E

    None of these

Show answer

Correct answer

  • C

    Sum of letter count of all the nouns that come after the first adjective in each sentence

Question 17

+2 marksOne correct option

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

text
A = 0, B = 0, C = 0
P = False, Q = True
while (Table 1 has more rows) {
Read the first row X in Table 1
if (X.PartOfSpeech == "Adjective") {
C = C + X.LetterCount
P = True
}
if (P and X.PartOfSpeech == "Noun") {
B = B + X.LetterCount
}
if (Q) {
A = A + X.LetterCount
Q = False
}
else {
if (X.Word ends with a full stop) {
A = A + X.LetterCount
Q = True
P = False
}
}
Move X to Table 2
}

Based on the above data, answer the given subquestions.

What will A represent at the end of execution?

  1. A

    Sum of letter count of first and last word of dataset

  2. B

    Sum of letter count of first and last word of first sentence

  3. C

    Sum of letter count of first and last word of last sentence

  4. D

    Sum of letter count of words first and last word of each sentence

  5. E

    None of these

Show answer

Correct answer

  • D

    Sum of letter count of words first and last word of each sentence

Question 18

+2 marksOne correct option

The following pseudocode constructs a graph from the “Words” dataset. A dictionary wordI is created. Each word in the dictionary, wordI, is considered as a node. The matrix W represents the graph. W[i][j]=1\mathbf{W[i][j]} = 1 if there is an edge from node i to node j.

text
i = 0
wordI = { }, wordF = { }
while (Table 1 has more rows) {
Read the first row X in Table 1
if (isKey(wordF, X.Word)) {
wordF[X.Word] = wordF[X.Word] + 1
}
else {
wordF[X.Word] = 1
wordI[X.Word] = i
i = i + 1
}
Move row X to Table 2
}
n = length(keys(wordI))
W = createMatrix(n, n)
foreach r in keys(wordI) {
foreach c in keys(wordI) {
if (r ≠ c and wordF[r] == wordF[c] and isDifferent(r, c)) {
W[wordI[r]] [wordI[c]] = 1
}
}
}
Procedure isDifferent(P, Q)
if (P.LetterCount == Q.LetterCount) {
return (False)
}
else {
return (True)
}
End isDifferent

Study the pseudocode given above and answer the subquestions:

There will be an edge between word i and word j if and only if:

  1. A

    The letter counts of word i and j are the same and both have the same frequency.

  2. B

    The letter counts of word i and j are different but both have the same frequency.

  3. C

    The letter counts of word i and j are different and both have different frequency.

  4. D

    The letter counts of word i and j are the same but both have different frequency.

  5. E

    None of these

Show answer

Correct answer

  • B

    The letter counts of word i and j are different but both have the same frequency.

Question 19

+1 markOne correct option

The following pseudocode constructs a graph from the “Words” dataset. A dictionary wordI is created. Each word in the dictionary, wordI, is considered as a node. The matrix W represents the graph. W[i][j]=1\mathbf{W[i][j]} = 1 if there is an edge from node i to node j.

text
i = 0
wordI = { }, wordF = { }
while (Table 1 has more rows) {
Read the first row X in Table 1
if (isKey(wordF, X.Word)) {
wordF[X.Word] = wordF[X.Word] + 1
}
else {
wordF[X.Word] = 1
wordI[X.Word] = i
i = i + 1
}
Move row X to Table 2
}
n = length(keys(wordI))
W = createMatrix(n, n)
foreach r in keys(wordI) {
foreach c in keys(wordI) {
if (r ≠ c and wordF[r] == wordF[c] and isDifferent(r, c)) {
W[wordI[r]] [wordI[c]] = 1
}
}
}
Procedure isDifferent(P, Q)
if (P.LetterCount == Q.LetterCount) {
return (False)
}
else {
return (True)
}
End isDifferent

Study the pseudocode given above and answer the subquestions:

Let N is the total number of words in the "Words" dataset. Choose the correct expression?

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

Correct answer

  • B

Question 20

+2 marksOne or more correct options

The following pseudocode constructs a graph from the “Words” dataset. A dictionary wordI is created. Each word in the dictionary, wordI, is considered as a node. The matrix W represents the graph. W[i][j]=1\mathbf{W[i][j]} = 1 if there is an edge from node i to node j.

text
i = 0
wordI = { }, wordF = { }
while (Table 1 has more rows) {
Read the first row X in Table 1
if (isKey(wordF, X.Word)) {
wordF[X.Word] = wordF[X.Word] + 1
}
else {
wordF[X.Word] = 1
wordI[X.Word] = i
i = i + 1
}
Move row X to Table 2
}
n = length(keys(wordI))
W = createMatrix(n, n)
foreach r in keys(wordI) {
foreach c in keys(wordI) {
if (r ≠ c and wordF[r] == wordF[c] and isDifferent(r, c)) {
W[wordI[r]] [wordI[c]] = 1
}
}
}
Procedure isDifferent(P, Q)
if (P.LetterCount == Q.LetterCount) {
return (False)
}
else {
return (True)
}
End isDifferent

Study the pseudocode given above and answer the subquestions:

Choose the correct statement(s) based on given pseudocode. It is a Multiple Select Question (MSQ).

Select all that apply.

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

Correct answers

  • B
  • D

Question 21

+2.5 marksOne or more correct options

doSomething is a procedure that accepts a non-empty list of integers L as input. The following pseudocode finds the biggest integer present in the input list. Choose the correct code fragment to complete the pseudocode. It is a Multiple Select Question (MSQ).

text
S = doSomething(L)
Procedure doSomething(L)
if (length(L) == 1) {
return(first(L))
}
else {
********************
* Fill the code *
********************
}
End doSomething

Select all that apply.

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

Correct answers

  • A
  • C

Question 22

+2.5 marksOne or more correct options

The following pseudocode is executed using the "Words" dataset. count represents the number of letters whose frequency is more than the average letter count. 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 A = { }
2 sum = 0
3 B = 0
4 count = 0
5 while (Table 1 has more rows) {
6 Read the first row X from Table 1
7 sum = sum + X.LetterCount
8 B = B + 1
9 i = 1
10 while (i < X.LetterCount) {
11 letter = ith letter of X.Word
12 if (isKey(A, letter )) {
13 A[letter] = 1
14 }
15 else {
16 A[letter] = A[letter] + 1
17 }
18 i = i + 1
19 }
20 Move the row X to Table 2
21 }
22 Avg = sum / B
23 foreach j in Keys(A) {
24 if (j > Avg) {
25 count = count + 1
26 }
27 }

Select all that apply.

  1. A

    Line 7: Incorrect update of sum

  2. B

    Line 9: Incorrect initialization of i

  3. C

    Line 10: Incorrect while-condition

  4. D

    Line 13: Incorrect update of A

  5. E

    Line 16: Incorrect update of A

  6. F

    Line 18: Misplaced update of i

  7. G

    Line 24: Incorrect if-condition

Show answer

Correct answers

  • C

    Line 10: Incorrect while-condition

  • D

    Line 13: Incorrect update of A

  • E

    Line 16: Incorrect update of A

  • G

    Line 24: Incorrect if-condition

Question 23

+2.5 marksOne or more correct options

Consider the following public procedures function1 and function2 that are defined inside a class Function (not shown here). Assume that variables aa and bb are private variables of Function.

text
Procedure function1( )
a = 2 * (b/2)
a = a * b
return (a)
End function1
text
Procedure function2( )
a = 4 * (b/2)
a = a * b
return (b)
End function2

We execute function1 and function2 in parallel, that is, at each step we execute either one statement from function1 or one statement from function2. If aa and bb are initialized to 4 and 2 respectively, then which of the following is not a possible value returned by function1? (It is a Multiple Select Question)(MSQ).

Select all that apply.

  1. A

    8

  2. B

    12

  3. C

    16

  4. D

    14

Show answer

Correct answers

  • B

    12

  • D

    14

Question 24

+2 marksOne correct option

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

text
D = { }
while (Table 1 has more rows) {
Read the first row X in Table 1
D[X.Seq_No] = X.Word
Move row X to Table 2
}
i = 0
a = 0, b = 0, c = 0, d = 0
aList = [ ], bList = [ ], cList = [ ], dList = [ ]
while (i < length(keys(D)) - 1) {
if (first letter of word D[i] is a vowel) {
if (first letter of word D[i +1] is a vowel) {
a = a + 1
aList = aList ++ [D[i]]
}
else {
b = b + 1
bList = bList ++ [D[i]]
}
}
else {
if (first letter of word D[i +1] is a vowel) {
c = c + 1
cList = cList ++ [D[i]]
}
else {
d = d + 1
dList = dList ++ [D[i]]
}
}
i = i + 1
}

Study the pseudocode given above and answer the subquestions:

What will the elements of list aList represent at the end of execution?

  1. A

    Words which begin with a vowel and followed by a word which begins with a vowel

  2. B

    Words which begin with a vowel and followed by a word which ends with a vowel

  3. C

    Words which end with a vowel and followed by a word which begins with a vowel

  4. D

    Words which end with a vowel and followed by a word which ends with a vowel

  5. E

    None of these

Show answer

Correct answer

  • A

    Words which begin with a vowel and followed by a word which begins with a vowel

Question 25

+1 markOne correct option

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

text
D = { }
while (Table 1 has more rows) {
Read the first row X in Table 1
D[X.Seq_No] = X.Word
Move row X to Table 2
}
i = 0
a = 0, b = 0, c = 0, d = 0
aList = [ ], bList = [ ], cList = [ ], dList = [ ]
while (i < length(keys(D)) - 1) {
if (first letter of word D[i] is a vowel) {
if (first letter of word D[i +1] is a vowel) {
a = a + 1
aList = aList ++ [D[i]]
}
else {
b = b + 1
bList = bList ++ [D[i]]
}
}
else {
if (first letter of word D[i +1] is a vowel) {
c = c + 1
cList = cList ++ [D[i]]
}
else {
d = d + 1
dList = dList ++ [D[i]]
}
}
i = i + 1
}

Study the pseudocode given above and answer the subquestions:

  1. A

    TRUE

  2. B

    FALSE

Show answer

Correct answer

  • B

    FALSE