Quiz Space

January 2022 term · Computational Thinking · BSCS1001

Computational Thinking End Term: 3 April 2022 (January 2022 term)

The IIT Madras BS Computational Thinking (Computational Thinking (CT)) End Term paper sat on 3 Apr 2022, in the January 2022 term: 27 questions for 100 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
27
Marks
100
Duration
180 min
MCQ
23
MSQ
3
Numerical
1

Updated

Official paper: IIT M FOUNDATION DIPLOMA ENDTERM FN1 3 Apr 2022 · No negative marking.

Question 1

+4 marksOne correct option

Let X and Y be two rows in the “Library” table. We call X and Y compatible if books in rows X and Y are either published in the same year or under the same genre but not both. Let Compatible(X, Y) be a procedure to find whether X and Y are compatible. Choose the correct implementation of the procedure Compatible.

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

Correct answer

  • D

Question 2

+3 marksOne correct option

The following pseudocode is executed using the “Scores” dataset. Two students form a study pair if the difference of their Mathematics marks is at most 10.

text
count1 = studyPair(Table 1)
while (Table 1 has more rows) {
Read the first row X in Table 1
if (X.CityTown == "Chennai") {
Move X to Table CHN
}
if (X.CityTown == "Bengaluru") {
Move X to Table BLR
}
if (X.CityTown == "Vellore") {
Move X to Table VLR
}
}
count2 = studyPair(Table CHN) + studyPair(Table BLR) + studyPair(Table VLR)
Procedure studyPair(Table 1)
Table T1 = Table 1
A = 0
while (Table T1 has more rows) {
Read the first row X in Table T1
Move X to Table T2
while (Table T1 has more rows) {
Read the first row Y in Table T1
Move Y to Table T3
if (-10 ≤ X.Mathematics - Y.Mathematics ≤ 10) {
A = A + 1
}
}
Move all rows from Table T3 to Table T1
}
return(A)
End studyPair

Based on the above data, answer the given subquestions.

What will count1 represent at the end of execution?

  1. A

    Number of study pairs

  2. B

    Number of pairs of study pairs

  3. C

    Number of students who formed study pairs

  4. D

    Number of study pairs from a same city

Show answer

Correct answer

  • A

    Number of study pairs

Question 3

+3 marksOne correct option

The following pseudocode is executed using the “Scores” dataset. Two students form a study pair if the difference of their Mathematics marks is at most 10.

text
count1 = studyPair(Table 1)
while (Table 1 has more rows) {
Read the first row X in Table 1
if (X.CityTown == "Chennai") {
Move X to Table CHN
}
if (X.CityTown == "Bengaluru") {
Move X to Table BLR
}
if (X.CityTown == "Vellore") {
Move X to Table VLR
}
}
count2 = studyPair(Table CHN) + studyPair(Table BLR) + studyPair(Table VLR)
Procedure studyPair(Table 1)
Table T1 = Table 1
A = 0
while (Table T1 has more rows) {
Read the first row X in Table T1
Move X to Table T2
while (Table T1 has more rows) {
Read the first row Y in Table T1
Move Y to Table T3
if (-10 ≤ X.Mathematics - Y.Mathematics ≤ 10) {
A = A + 1
}
}
Move all rows from Table T3 to Table T1
}
return(A)
End studyPair

Based on the above data, answer the given subquestions.

What will count2 represent at the end of execution?

  1. A

    Number of study pairs where students in each pair are from the same city

  2. B

    Number of study pairs where students in each pair are from different cities among Chennai, Bengaluru and Vellore

  3. C

    Number of study pairs where students in each pair are from the same city among Chennai, Bengaluru and Vellore

  4. D

    Number of study pairs where students in each pair are from Chennai

Show answer

Correct answer

  • C

    Number of study pairs where students in each pair are from the same city among Chennai, Bengaluru and Vellore

Question 4

+3 marksOne correct option

Consider a graph generated from n rows of “Scores” table that is represented by a matrix M. Each node in the graph corresponds to a student from the table. SeqNo is used to label the nodes in the graph. Study the given pseudocode and answer the given subquestions.

text
M = createMatrix(n, n)
foreach i in rows(M) {
foreach j in columns(M) {
M[i][j] = [ ]
}
}
L = ["Chemistry", "Mathematics", "Physics"]
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
foreach Subject in L {
if (X.Subject > Y.Subject) {
M[X.SeqNo][Y.SeqNo] = M[X.SeqNo][Y.SeqNo] ++ [Subject]
}
if (X.Subject < Y.Subject) {
M[Y.SeqNo][X.SeqNo] = M[Y.SeqNo][X.SeqNo] ++ [Subject]
}
}
}
Move all rows from Table 3 to Table 1
}
  1. A

    M[i][j] is a list of subjects in which i scores more than j

  2. B

    M[i][j] is the number of subjects in which i scores more than j

  3. C

    M[i][j] is a list of subjects in which i scores less than j

  4. D

    M[i][j] is the number of subjects in which i scores less than j

Show answer

Correct answer

  • A

    M[i][j] is a list of subjects in which i scores more than j

Question 5

+3 marksOne correct option

Consider a graph generated from n rows of “Scores” table that is represented by a matrix M. Each node in the graph corresponds to a student from the table. SeqNo is used to label the nodes in the graph. Study the given pseudocode and answer the given subquestions.

text
M = createMatrix(n, n)
foreach i in rows(M) {
foreach j in columns(M) {
M[i][j] = [ ]
}
}
L = ["Chemistry", "Mathematics", "Physics"]
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
foreach Subject in L {
if (X.Subject > Y.Subject) {
M[X.SeqNo][Y.SeqNo] = M[X.SeqNo][Y.SeqNo] ++ [Subject]
}
if (X.Subject < Y.Subject) {
M[Y.SeqNo][X.SeqNo] = M[Y.SeqNo][X.SeqNo] ++ [Subject]
}
}
}
Move all rows from Table 3 to Table 1
}

Which of the following indicates that student i has scored the minimum marks in subject S?

  1. A

    S appears in M[i][j] for every j

  2. B

    S appears in M[j][i] for every j

  3. C

    S does not appear in M[i][j] for any j

  4. D

    S does not appear in M[j][i] for any j

Show answer

Correct answer

  • C

    S does not appear in M[i][j] for any j

Question 6

+4 marksOne correct option

Consider a graph generated from the “Words” table that is represented by a matrix M. Each node in the graph corresponds to a word from the table. SeqNo is used to label the nodes in the graph. Study the given pseudocode and answer the given subquestions.

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

There will be an edge from word i to j if:

  1. A

    The letter count and part of speech of words i and j are same

  2. B

    The letter count of word i is more than j and both have same part of speech

  3. C

    The letter count of word i is one more than j and both have same part of speech

  4. D

    The letter count of word j is one more than i and both have same part of speech

Show answer

Correct answer

  • C

    The letter count of word i is one more than j and both have same part of speech

Question 7

+2 marksOne correct option

Consider a graph generated from the “Words” table that is represented by a matrix M. Each node in the graph corresponds to a word from the table. SeqNo is used to label the nodes in the graph. Study the given pseudocode and answer the given subquestions.

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

Every pair of nodes with the same part of speech is connected by an edge.

  1. A

    TRUE

  2. B

    FALSE

Show answer

Correct answer

  • B

    FALSE

Question 8

+3 marksOne correct option

Let M be an adjacency matrix of a graph G given below, where M[i][j] = 1 if there is an edge from i to j, otherwise 0. Study the given pseudocode and answer the given subquestions.

What will be the values of A and B at the end of execution of pseudocode given below?

  1. A

    A = 1, B = 1

  2. B

    A = 1, B = 0

  3. C

    A = 0, B = 1

  4. D

    A = 0, B = 0

Show answer

Correct answer

  • D

    A = 0, B = 0

Question 9

+3 marksOne correct option

Let M be an adjacency matrix of a graph G given below, where M[i][j] = 1 if there is an edge from i to j, otherwise 0. Study the given pseudocode and answer the given subquestions.

What will be the values of A and B at the end of execution of pseudocode given below?

  1. A

    A = 1, B = 1

  2. B

    A = 1, B = 0

  3. C

    A = 0, B = 1

  4. D

    A = 0, B = 0

Show answer

Correct answer

  • B

    A = 1, B = 0

Question 10

+4 marksOne correct option

Consider the following graph with five nodes. A is the 5 × 5 adjacency matrix corresponding to this graph.

Based on the above data, answer the given subquestions.

What will be the value of S after executing the given pseudocode?

  1. A

    S = [0, 1, 2, 3, 4]

  2. B

    S = [0, 1, 2, 4, 3]

  3. C

    S = [0, 1, 3, 2, 4]

  4. D

    S = [0, 1, 3, 4, 2]

Show answer

Correct answer

  • D

    S = [0, 1, 3, 4, 2]

Question 11

+2 marksOne correct option

Consider the following graph with five nodes. A is the 5 × 5 adjacency matrix corresponding to this graph.

Based on the above data, answer the given subquestions.

What will be the value of keys(P) after executing the given pseudocode?

  1. A

    keys(P) = [0, 1, 2, 3, 4]

  2. B

    keys(P) = [0, 1, 2, 4, 3]

  3. C

    keys(P) = [0, 1, 3, 2, 4]

  4. D

    keys(P) = [0, 1, 3, 4, 2]

  5. E

    Cannot be determined

Show answer

Correct answer

  • E

    Cannot be determined

Question 12

+5 marksOne correct option

A word is said to be perfect if no letter is repeated. Let isPerfect be a procedure that takes a row X in the “Words” table as input and decides whether the word is perfect. Choose the correct implementation of the procedure isPerfect.

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

Correct answer

  • B

Question 13

+5 marksOne correct option

The given pseudocode is executed using the “Words” dataset. C stores the number of nouns which have at least one verb adjacent to it. Choose the correct code fragment to complete the pseudocode.

text
V = [ ], N = [ ], C = 0
while (Table 1 has more rows) {
Read the first row X in Table 1
if (X.PartOfSpeech == "Verb") {
V = V ++ [X.SeqNo]
}
if (X.PartOfSpeech == "Noun") {
N = N ++ [X.SeqNo]
}
Move X to Table 2
}
********************
* Fill the code *
********************
  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • A

Question 14

+5 marksOne correct option

The following pseudocode is executed using the “Scores” table. At the end of the execution, D captures the following information: D[A][B] stores the highest marks scored in subject B by a student from city A. Choose the correct code fragment to complete the pseudocode.

text
D = { }
L = ["Physics", "Chemistry", "Mathematics"]
while (Table 1 has more rows) {
Read the first row X in Table 1
**********************
* Fill the code *
**********************
Move X to Table 2
}
  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • C

Question 15

+5 marksOne correct option

The following pseudocode is executed using the “Scores” dataset. What will the value of L represent at the end of the execution?

text
cityMarks = { }
while (Table 1 has more rows) {
Read the first row X in Table 1
if (isKey(cityMarks, X.CityTown)) {
cityMarks[X.CityTown] = cityMarks[X.CityTown] ++ [X.Total]
}
else {
cityMarks[X.CityTown] = [X.Total]
}
Move row X to Table 2
}
A = 0, L = [ ]
foreach c in keys(cityMarks) {
data = doSomething(cityMarks[c])
B = first(data) − last(data)
if (B == A) {
L = L ++ [c]
}
if (B > A) {
A = B
L = [c]
}
}
Procedure doSomething(Y)
p = 0, q = 301
foreach k in Y{
if (k > p) {
p = k
}
if (k < q) {
q = k
}
}
return([p, q])
End doSomething
  1. A

    List of cities in which the difference of highest total and lowest total marks of students is same

  2. B

    List of cities in which the difference of highest total and lowest total marks of students is maximum

  3. C

    List of cities in which the difference of highest total and lowest total marks of students is minimum

  4. D

    List of cities in which the difference of highest total and lowest total marks of students is 301

Show answer

Correct answer

  • B

    List of cities in which the difference of highest total and lowest total marks of students is maximum

Question 16

+5 marksOne correct option

The given pseudocode is executed using the “Words” dataset. What will A represent at the end of execution?

text
D = { }, A = 0
while (Table 1 has more rows) {
Read the first row X in Table 1
D = updateDictionary(D, X)
Move X to Table 2
}
foreach C in keys(D) {
if (C is a vowel and D[C] > A) {
A = D[C]
}
}
Procedure updateDictionary(D, Y)
i = 1
while (i ≤ Y.LetterCount) {
B = ith letter in Y.Word
if (isKey(D, B)) {
D[B] = D[B] + 1
}
else {
D[B] = 1
}
i = i + 1
}
return (D)
End updateDictionary
  1. A

    Frequency count of a vowel which occurs in maximum number of words in the dataset

  2. B

    Frequency count of a vowel which occurs maximum times in a single word

  3. C

    Frequency count of a vowel which occurs in maximum number of sentences in the dataset

  4. D

    Frequency count of the most frequent vowel in the dataset

Show answer

Correct answer

  • D

    Frequency count of the most frequent vowel in the dataset

Question 17

+5 marksOne or more correct options

A word is said to be a palindrome if the word obtained by reversing its letters is the same as the original word. For example, madam is a palindrome. The following pseudocode picks up a word X from the “Words” table and checks if it is a palindrome or not. The result is stored in a boolean variable called flag. Select the correct implementation of the procedure isPalindrome. This procedure must return True if the word is a palindrome and False otherwise. It is a Multiple Select Question (MSQ).

text
wordList = wordToList(X)
flag = isPalindrome(wordList)
********************
* Fill the code *
********************
Procedure wordToList(X)
i = 1
chars = [ ]
while (i <= X.LetterCount) {
chars = chars ++ [ith letter of X.Word]
i = i + 1
}
return (chars)
End wordToList

Select all that apply.

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

Correct answers

  • A
  • C

Question 18

+3 marksOne correct option

The following pseudocode is executed using the “Words” dataset. Study the given pseudocode and answer the given subquestions.

text
A = 0, flag = True
inList = [ ], outList = [ ]
while (Table 1 has more rows) {
Read the first row X in Table 1
if (flag) {
inList = [X.Word]
flag = False
}
if (X.Word ends with a full stop) {
outList = outList ++ [[X.Word] ++ inList]
A = A + 1
inList = [ ]
flag = True
}
Move X to Table 2
}

What will outList represent at the end of execution?

  1. A

    List of lists of last word of each sentence

  2. B

    List of lists of first word of each sentence

  3. C

    List of lists of last and first word of each sentence in that order

  4. D

    List of lists of first and last word of each sentence in that order

  5. E

    List of lists of first and last word of each sentence in any order

Show answer

Correct answer

  • C

    List of lists of last and first word of each sentence in that order

Question 19

+2 marksOne correct option

The following pseudocode is executed using the “Words” dataset. Study the given pseudocode and answer the given subquestions.

text
A = 0, flag = True
inList = [ ], outList = [ ]
while (Table 1 has more rows) {
Read the first row X in Table 1
if (flag) {
inList = [X.Word]
flag = False
}
if (X.Word ends with a full stop) {
outList = outList ++ [[X.Word] ++ inList]
A = A + 1
inList = [ ]
flag = True
}
Move X to Table 2
}

The values of length(outList) and A will be same at the end of execution.

  1. A

    TRUE

  2. B

    FALSE

Show answer

Correct answer

  • A

    TRUE

Question 20

+3 marksOne correct option

Consider a graph generated from the “Scores” table that is represented by a matrix M. Each node in the graph corresponds to a student from the table. SeqNo is used to label the nodes in the graph. Study the given pseudocode and answer the given subquestions.

text
A = { }
while (Table 1 has more rows) {
Read the first row X in Table 1
A[X.SeqNo] = [X.CityTown, X.Gender]
Move 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 isRelated(A[i], A[j])) {
M[i][j] = 1
}
}
}
Procedure isRelated(Y, Z)
if (first(Y) == first(Z) and last(Y) == last(Z)) {
return (True)
}
else {
return (False)
}
End isRelated
  1. A

    they are from the same city/town

  2. B

    they have the same gender

  3. C

    they are from the same city/town and have the same gender

  4. D

    they are from the same city/town or have the same gender

Show answer

Correct answer

  • C

    they are from the same city/town and have the same gender

Question 21

+4 marksOne or more correct options

Consider a graph generated from the “Scores” table that is represented by a matrix M. Each node in the graph corresponds to a student from the table. SeqNo is used to label the nodes in the graph. Study the given pseudocode and answer the given subquestions.

text
A = { }
while (Table 1 has more rows) {
Read the first row X in Table 1
A[X.SeqNo] = [X.CityTown, X.Gender]
Move 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 isRelated(A[i], A[j])) {
M[i][j] = 1
}
}
}
Procedure isRelated(Y, Z)
if (first(Y) == first(Z) and last(Y) == last(Z)) {
return (True)
}
else {
return (False)
}
End isRelated

Which of the following statements are true about this graph? It is a Multiple Select Question (MSQ).

Select all that apply.

  1. A

    There are only two cliques in this graph

  2. B

    All students in a given clique have the same gender

  3. C

    The graph is undirected

  4. D

    All students in a given clique can be from different cities/towns

Show answer

Correct answers

  • B

    All students in a given clique have the same gender

  • C

    The graph is undirected

Question 22

+4 marksOne correct option

Consider a graph generated from the “Scores” table that is represented by a matrix M. Each node in the graph corresponds to a student from the table. SeqNo is used to label the nodes in the graph. Study the given pseudocode and answer the given subquestions.

text
D = { }
while (Table 1 has more rows) {
Read the first row X in Table 1
D[X.SeqNo] = {"P": X.Physics, "C": X.Chemistry, "M": X.Mathematics}
Move X to Table 2
}
Ph = getAdjMatrix(D, "P")
Ch = getAdjMatrix(D, "C")
Ma = getAdjMatrix(D, "M")
Procedure getAdjMatrix(D, Subject)
n = length(keys(D))
M = createMatrix(n,n)
foreach i in rows(M) {
foreach j in columns(M) {
if (i ≠ j) {
diff = D[i][Subject] - D[j][Subject]
if (10 ≤ diff and diff≤ 20) {
M[i][j] = 1
}
}
}
}
return (M)
End getAdjMatrix

Choose the correct statement based on given pseudocode.

  1. A

    For all i, j, if Ph[i][j] = 1 then Ph[j][i] = 0

  2. B

    For all i, j, if Ph[i][j] = 0 then Ph[j][i] = 1

  3. C

    For all i, j, if Ph[i][j] = 1 then Ph[j][i] = 1

  4. D

    For all i, j, if Ph[i][j] = 0 then Ph[j][i] = 0

Show answer

Correct answer

  • A

    For all i, j, if Ph[i][j] = 1 then Ph[j][i] = 0

Question 23

+4 marksOne or more correct options

Consider a graph generated from the “Scores” table that is represented by a matrix M. Each node in the graph corresponds to a student from the table. SeqNo is used to label the nodes in the graph. Study the given pseudocode and answer the given subquestions.

text
D = { }
while (Table 1 has more rows) {
Read the first row X in Table 1
D[X.SeqNo] = {"P": X.Physics, "C": X.Chemistry, "M": X.Mathematics}
Move X to Table 2
}
Ph = getAdjMatrix(D, "P")
Ch = getAdjMatrix(D, "C")
Ma = getAdjMatrix(D, "M")
Procedure getAdjMatrix(D, Subject)
n = length(keys(D))
M = createMatrix(n,n)
foreach i in rows(M) {
foreach j in columns(M) {
if (i ≠ j) {
diff = D[i][Subject] - D[j][Subject]
if (10 ≤ diff and diff≤ 20) {
M[i][j] = 1
}
}
}
}
return (M)
End getAdjMatrix

Choose the correct statement(s) based on given pseudocode. It is a Multiple Select Question (MSQ).
For all i, j,

Select all that apply.

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

Correct answers

  • A
  • D

Question 24

+4 marksNumerical answer

The procedure calculate takes two positive integers as arguments and returns an integer. Study the given pseudocode and answer the given subquestions.

What does calculate(3, 2) return?
NOTE: Enter your answer to the nearest integer.

Show answer

Correct answer: 8

Question 25

+4 marksOne correct option

The procedure calculate takes two positive integers as arguments and returns an integer. Study the given pseudocode and answer the given subquestions.

Which of the following is the output returned by calculate(x, y)?

  1. A

    y + x + (x − 1) + · · · + 1

  2. B

    x + (x − 1) + · · · + 1

  3. C

    x + y + (y − 1) + · · · + 1

  4. D

    x · y

Show answer

Correct answer

  • A

    y + x + (x − 1) + · · · + 1

Question 26

+4 marksOne correct option

Consider the given pseudocode, two positive integers, a and b are the input parameters of procedure mystery, where a ≥ b.

text
A = mystery(a, b)
Procedure mystery(X, Y)
if (Y≠ 0) {
return(mystery(Y, doSomething(X, Y)))
}
else {
return(X)
}
End mystery
Procedure doSomething(U, V)
if (U ≠ V){
C = 0, i = 0
while (C ≤ U){
i = i + 1
C = V * i
}
D = U - V * (i - 1)
return(D)
}
else {
return(0)
}
End doSomething

Based on the above data, answer the given subquestions.

What will the return value of procedure doSomething(U, V) represent, where U ≥ V?

  1. A

    Remainder when V is divided by U

  2. B

    Remainder when U is divided by V

  3. C

    Quotient when V is divided by U

  4. D

    Quotient when U is divided by V

  5. E

    Can not say anything

Show answer

Correct answer

  • B

    Remainder when U is divided by V

Question 27

+4 marksOne correct option

Consider the given pseudocode, two positive integers, a and b are the input parameters of procedure mystery, where a ≥ b.

text
A = mystery(a, b)
Procedure mystery(X, Y)
if (Y≠ 0) {
return(mystery(Y, doSomething(X, Y)))
}
else {
return(X)
}
End mystery
Procedure doSomething(U, V)
if (U ≠ V){
C = 0, i = 0
while (C ≤ U){
i = i + 1
C = V * i
}
D = U - V * (i - 1)
return(D)
}
else {
return(0)
}
End doSomething

Based on the above data, answer the given subquestions.

What will A represent at the end of the execution?

  1. A

    LCM of positive integers, a and b

  2. B

    HCF (GCD) of positive integers, a and b

  3. C

    Product of integers, a and b

  4. D

    Sum of integers, a and b

Show answer

Correct answer

  • B

    HCF (GCD) of positive integers, a and b