Question 21
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)
1 A = { }2 sum = 03 B = 04 count = 05 while (Table 1 has more rows) {6 Read the first row X from Table 17 sum = sum + X.LetterCount8 B = B + 19 i = 010 while (i ≤ X.LetterCount) {11 letter = ith letter of X.Word12 if (isKey(A, letter )) {13 A[letter] = A[letter] + 114 }15 else {16 A[letter] = 117 }18 i = i + 119 }20 Move the row X to Table 221 }22 Avg = sum / B23 foreach j in Keys(A) {24 if (A[j] < Avg) {25 count = count + 126 }27 }Line 7: Incorrect update of sum
Line 9: Incorrect initialization of i
Line 10: Incorrect while-condition
Line 13: Incorrect update of A
Line 16: Incorrect update of A
Line 18: Misplaced update of i
Line 24: Incorrect if-condition