Question 13
A sentence is said to be balanced if there are equal numbers of vowels and consonants in it. The following pseudocode is executed using the "Words" dataset. At the end of execution, Bcount counts the number of balanced sentences. But the pseudocode may have mistakes. Identify all such mistakes (if any). It is a Multiple Select Question (MSQ).
1 Bcount = 0 2 CountV = 0, CountC = 0 3 while (Table 1 has more rows) { 4 Read the first row X in Table 1 5 CountV, CountC = countSomething(X, CountV, CountC) 6 if (X.Word ends with a full stop) { 7 if (CountV ≠ CountC) { 8 Bcount = Bcount + 1 9 }10 }11 CountV = 0, CountC = 012 Move the row X to Table 213 }
14 Procedure countSomething(Y, A, B)15 i = 016 while (i ≤ Y.LetterCount) {17 if (ith letter of Y.Word is vowel) {18 A = A + 119 }20 else {21 B = B + 122 }23 i = i + 124 }25 return ([A, B])26 End countSomethingLine 2, incorrect initialization of CountV and CountC
Line 7, incorrect if condition
Line 8, invalid update of Bcount
Line 11, misplaced re-initialization of CountV and CountC
Line 15, incorrect initialization of i
Line 21, incorrect increment of B
Line 25, incorrect return value
No error