Question 19
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.
i = 0wordI = { }, 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 isSimilarStudy the pseudocode above and answer the given subquestions:
Choose the correct statement(s) based on given pseudocode. It is a Multiple Select Question (MSQ).
For all i, j with i ≠ j, if W[i][j] = 0 then W[j][i] = 1
For all i, j with i ≠ j, if W[i][j] = 1 then W[j][i] = 1
For all i, j with i ≠ j, if W[i][j] = 1 then W[j][i] = 0
For all i, j with i ≠ j, if W[i][j] = 0 then W[j][i] = 0