Question 18
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. 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 isDifferent(r, c)) { W[wordI[r]] [wordI[c]] = 1 } }}
Procedure isDifferent(P, Q) if (P.LetterCount == Q.LetterCount) { return (False) } else { return (True) }End isDifferentStudy the pseudocode given above and answer the subquestions:
There will be an edge between word i and word j if and only if:
The letter counts of word i and j are the same and both have the same frequency.
The letter counts of word i and j are different but both have the same frequency.
The letter counts of word i and j are different and both have different frequency.
The letter counts of word i and j are the same but both have different frequency.
None of these