Quiz Space

May 2021 term · Computational Thinking · BSCS1001

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

The IIT Madras BS Computational Thinking (Computational Thinking (CT)) End Term paper sat on 22 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: IITM TERM FINAL EXAM POD21TEFNQPA 22 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 == 'F' 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 female students

  2. B

    Number of female students + Number of students from Chennai

  3. C

    Number of female students + Number of male students from Chennai

  4. D

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

  5. E

    None of these

Show answer

Correct answer

  • A

    Number of female students

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 = True, B = False, count = 0
while (Table 1 has more rows) {
Read the first row X from Table 1
if (X.PartOfSpeech == "Pronoun") {
A = False
}
if (X.ParsOfSpeech == "Noun") {
B = True
}
if (X.PartOfSpeech == "Adjective") {
if (not (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 a pronoun

  3. C

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

  4. D

    Number of adjectives before a noun and after a pronoun

Show answer

Correct answer

  • C

    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 == "English") {
A = A + 1
if (X.language == "Fiction") {
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 other than in English language

  4. D

    Number of books other than in English language + Number of fiction books in English.

Show answer

Correct answer

  • D

    Number of books other than in English language + 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 (A + C) – (B + D) 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 at most 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

  • B

    Number of authors who wrote at most 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

  • D

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

Question 7

+2 marksOne correct option

Consider the following pseudocode.

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

  1. A

    12

  2. B

    16

  3. C

    20

  4. D

    24

Show answer

Correct answer

  • D

    24

Question 8

+2 marksOne correct option

Consider a matrix M generated from the "Words" dataset. If i and j represents 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 and same letter count

  2. B

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

  3. C

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

  4. D

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

Show answer

Correct answer

  • C

    If i and j have different part of speech but same 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] < 6) {
count1 = count1+ 1
}
else {
count2 = count2+ 1
}
}
  1. A

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

  2. B

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

  3. C

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

  4. D

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

Show answer

Correct answer

  • D

    If the number of players who have won at least 6 medals is greater than the number of players who have won less than 6 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 maximum number of books

  2. B

    List of authors who published the first book 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 in the most recent year

  5. E

    None of these

Show answer

Correct answer

  • B

    List of authors who published the first 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 = 301, 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(last(L))
}
else {
return(last(L) + doSomething(init(L)))
}
End doSomething
  1. A

    List of students who got minimum total marks

  2. B

    List of cities with minimum total marks

  3. C

    List of cities with minimum average total marks

  4. D

    List of cities with minimum average marks

  5. E

    None of these

Show answer

Correct answer

  • C

    List of cities with minimum average total marks

Question 12

+2.5 marksOne correct option
  1. A

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

  2. B

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

  3. C

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

  4. D

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

  5. E

    None of these

Show answer

Correct answer

  • A

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

Question 13

+2 marksOne or more correct options

Consider the definition of the object datatype ClassDict.

text
ClassDict
private fields:
Dict, keys
private procedures:
Procedure isKey(D, k)
foreach i in keys(D) {
if (i == k) {
return (True)
}
}
return (False)
End isKey
public procedures:
Procedure initialize( )
Dict = { }
keys = [ ]
End initialize
Procedure addElement(key, value)
if (not isKey(Dict, key)) {
Dict[key] = value
keys = keys ++ [key]
}
End addElement
End ClassDict

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

Select all that apply.

  1. A

    cD.initialize cannot be called directly.

  2. B

    cD.Dict, cD.keys cannot be updated directly.

  3. C

    Many objects like cD of datatype ClassDict can be created.

  4. D

    The procedure addElement returns Dict.

Show answer

Correct answers

  • B

    cD.Dict, cD.keys cannot be updated directly.

  • C

    Many objects like cD of datatype ClassDict can be created.

Question 14

+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 (P) {
if (X.PartOfSpeech == "Verb") {
B = B + X.LetterCount
}
}
if (X.PartOfSpeech == "Noun") {
C = C + X.LetterCount
P = True
}
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 nouns

  2. B

    Sum of letter count of all nouns

  3. C

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

  4. D

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

Show answer

Correct answer

  • B

    Sum of letter count of all nouns

Question 15

+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 (P) {
if (X.PartOfSpeech == "Verb") {
B = B + X.LetterCount
}
}
if (X.PartOfSpeech == "Noun") {
C = C + X.LetterCount
P = True
}
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 verbs which come after a noun

  2. B

    Sum of letter count of all verbs which come next to a noun

  3. C

    Sum of letter count of all verbs which come after a noun in each sentence

  4. D

    Sum of letter count of all verbs which come next to a noun in each sentence

  5. E

    None of these

Show answer

Correct answer

  • C

    Sum of letter count of all verbs which come after a noun in each sentence

Question 16

+1.5 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 (P) {
if (X.PartOfSpeech == "Verb") {
B = B + X.LetterCount
}
}
if (X.PartOfSpeech == "Noun") {
C = C + X.LetterCount
P = True
}
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 17

+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 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 isSimilar(r, c)) {
W[wordI[r]] [wordI[c]] = 1
}
}
}
Procedure isSimilar(P, Q)
if (P.PartOfSpeech == Q.PartOfSpeech) {
return (True)
}
else {
return (False)
}
End isSimilar

Study the pseudocode above and answer the given subquestions:

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

  1. A

    The part of speech of word i and j are different but both have the same frequency.

  2. B

    The part of speech of word i and j are same and both have the same frequency.

  3. C

    The part of speech of word i and j are different and both have different frequencies.

  4. D

    The part of speech of word i and j are same but both have different frequencies.

  5. E

    None of these

Show answer

Correct answer

  • D

    The part of speech of word i and j are same but both have different frequencies.

Question 18

+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 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 isSimilar(r, c)) {
W[wordI[r]] [wordI[c]] = 1
}
}
}
Procedure isSimilar(P, Q)
if (P.PartOfSpeech == Q.PartOfSpeech) {
return (True)
}
else {
return (False)
}
End isSimilar

Study the pseudocode above and answer the given subquestions:

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

  1. A

    N == n

  2. B

    N ≥ n

  3. C

    N ≤ n

  4. D

    None of these

Show answer

Correct answer

  • B

    N ≥ n

Question 19

+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 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 isSimilar(r, c)) {
W[wordI[r]] [wordI[c]] = 1
}
}
}
Procedure isSimilar(P, Q)
if (P.PartOfSpeech == Q.PartOfSpeech) {
return (True)
}
else {
return (False)
}
End isSimilar

Study the pseudocode above and answer the given subquestions:

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

Select all that apply.

  1. A

    For all i, j with i ≠ j, if W[i][j] = 0 then W[j][i] = 1

  2. B

    For all i, j with i ≠ j, if W[i][j] = 1 then W[j][i] = 1

  3. C

    For all i, j with i ≠ j, if W[i][j] = 1 then W[j][i] = 0

  4. D

    For all i, j with i ≠ j, if W[i][j] = 0 then W[j][i] = 0

Show answer

Correct answers

  • B

    For all i, j with i ≠ j, if W[i][j] = 1 then W[j][i] = 1

  • D

    For all i, j with i ≠ j, if W[i][j] = 0 then W[j][i] = 0

Question 20

+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 smallest 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

  • B
  • D

Question 21

+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 = 0
10 while (i ≤ X.LetterCount) {
11 letter = ith letter of X.Word
12 if (isKey(A, letter )) {
13 A[letter] = A[letter] + 1
14 }
15 else {
16 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 (A[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

  • B

    Line 9: Incorrect initialization of i

  • G

    Line 24: Incorrect if-condition

Question 22

+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 1 and 2 respectively, then which of the following are not possible values 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 23

+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) {
j = D[i].LetterCount
if (jᵗʰ 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 above and answer the given 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

  • C

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

Question 24

+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) {
j = D[i].LetterCount
if (jᵗʰ 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 above and answer the given subquestions:

(a+b+c+d) will give the total number of words present in "Words" dataset.

  1. A

    TRUE

  2. B

    FALSE

Show answer

Correct answer

  • B

    FALSE

Question 25

+3 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 = False
A = { }
foreach i in l {
if (isKey(A, i)) {
A[i] = A[i] + 1
}
else {
A[i] = 1
}
}
if (length(keys(A)) == 1) {
Flag = True
}
return (Flag)
End seeSomething
  1. A

    If all books published by i are of a single genre and all books published by j are of a single genre.

  2. B

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

  3. C

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

  4. D

    If i has published same number of books and j has published same number of books.

  5. E

    None of these

Show answer

Correct answer

  • A

    If all books published by i are of a single genre and all books published by j are of a single genre.