InterviewSolution
Saved Bookmarks
| 1. |
The following pseudocode is executed using the “Words” table. What will be the value of A at the end of the execution? [6 Marks]Sum = 0, SumT = 0Count = 0, CountT = 0while (Table 1 has more rows) {Read the first row X in Table 1Sum, Count = AddWord(X, Sum, Count)Move X to Table 2}B = Sum / CountSum = 0, Count = 0, A = 0Move all rows from Table 2 to Table 1while (Table 1 has more rows) {Read the first row X in Table 1Sum, Count = AddWord(X, Sum, Count)if (X.Word ends with a full stop) {C = Sum / CountA = DoSomething(C, B, A)Sum = 0, Count = 0}Move X to Table 2}Procedure AddWord (Y, SumT, CountT)SumT = SumT + Y.LetterCountCountT = CountT + 1return ([SumT, CountT])End AddWordProcedure DoSomething (P, Q, R)if (P < Q) {return (R + 1)}else {return (R)}End DoSomething |
| Answer» | |