Quiz Space

Computational Thinking · End Term · 22 Aug 2021 · May 2021 term

Question 17: The following pseudocode constructs a graph from the "Wo…

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 17 of 25 in the IIT Madras BS Computational Thinking (Computational Thinking (CT)) End Term paper sat on 22 Aug 2021, in the May 2021 term (IITM TERM FINAL EXAM POD21TEFNQPA 22 Aug 2021). It carries 2 marks.

More questions from this paper

  1. Q1The following pseudocode is executed using the "Scores" dataset. What will B represent at the end of execution of pseud…
  2. Q2The following pseudocode is executed using the "Words" dataset. What does count represent at the end of execution?
  3. Q3The following pseudocode is executed using the "Library" dataset. What does (count – A+B) represent at the end of execu…
  4. Q4The following pseudocode is executed using the "Scores" dataset? What will (A + C) – (B + D) represent at the end of ex…
  5. Q5The following pseudocode is executed using the "Library" dataset. What does the count represent at the end of execution?
  6. Q6The following pseudocode is executed using the "Scores" dataset. What does List store at the end of execution?
  7. Q7Consider the following pseudocode. How many times will the procedure nfib( ) be called if n = 5, excluding the main cal…
  8. Q8Consider a matrix M generated from the "Words" dataset. If i and j represents two different words, when will M[i][j] be…
  9. Q9The following pseudocode is executed using the "Olympics" dataset. When will count2 be greater than count1?
  10. Q10The following pseudocode is executed using the "Library" dataset. What will L represent at the end of execution?
  11. Q11The following pseudocode is executed using the "Scores" dataset. What will B represent at the end of the execution?
  12. Q12Figure question
  13. Q13Consider the definition of the object datatype ClassDict. Let cD be a ClassDict object. Choose the correct statement(s)…
  14. Q14The following pseudocode is executed using the "Words" dataset? Based on the above data, answer the given subquestions.…
  15. Q15The following pseudocode is executed using the "Words" dataset? Based on the above data, answer the given subquestions.…
  16. Q16The following pseudocode is executed using the "Words" dataset? Based on the above data, answer the given subquestions.…
  17. Q18The following pseudocode constructs a graph from the "Words" dataset. A dictionary wordI is created. Each word in the d…
  18. Q19The following pseudocode constructs a graph from the "Words" dataset. A dictionary wordI is created. Each word in the d…
  19. Q20doSomething is a procedure that accepts a non-empty list of integers L as input. The following pseudocode finds the sma…
  20. Q21The following pseudocode is executed using the "Words" dataset. count represents the number of letters whose frequency …
  21. Q22Consider the following public procedures function1 and function2 that are defined inside a class Function (not shown he…
  22. Q23The following pseudocode is executed using the "Words" dataset Study the pseudocode above and answer the given subquest…
  23. Q24The following pseudocode is executed using the "Words" dataset Study the pseudocode above and answer the given subquest…
  24. Q25The following table contains information regarding the books in "Library" dataset. Each entry in the table corresponds …