Quiz Space

Computational Thinking · Qualifier · 7 Aug 2022 · May 2022 term

Question 13: A sentence is said to be balanced if there are equal num…

Question 13

+5 marksOne or more correct options

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).

text
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 = 0
12 Move the row X to Table 2
13 }
14 Procedure countSomething(Y, A, B)
15 i = 0
16 while (i ≤ Y.LetterCount) {
17 if (ith letter of Y.Word is vowel) {
18 A = A + 1
19 }
20 else {
21 B = B + 1
22 }
23 i = i + 1
24 }
25 return ([A, B])
26 End countSomething

Select all that apply.

  1. A

    Line 2, incorrect initialization of CountV and CountC

  2. B

    Line 7, incorrect if condition

  3. C

    Line 8, invalid update of Bcount

  4. D

    Line 11, misplaced re-initialization of CountV and CountC

  5. E

    Line 15, incorrect initialization of i

  6. F

    Line 21, incorrect increment of B

  7. G

    Line 25, incorrect return value

  8. H

    No error

Show answer

Correct answers

  • B

    Line 7, incorrect if condition

  • D

    Line 11, misplaced re-initialization of CountV and CountC

  • E

    Line 15, incorrect initialization of i

Question 13 of 14 in the IIT Madras BS Computational Thinking (Computational Thinking (CT)) Qualifier paper sat on 7 Aug 2022, in the May 2022 term (IIT M QUALIFIER EXAM QPE 07 Aug 2022 IBA NS). It carries 5 marks.

More questions from this paper

  1. Q1The following pseudocode is executed using the "Words" dataset. What will A represent at the end of execution?
  2. Q2The following pseudocode is executed using the "Olympics" dataset. Assume that no player won more than one medal. What …
  3. Q3The following pseudocode is executed using the "Scores" dataset. What will Count represent at the end of execution? It …
  4. Q4The following pseudocode is executed using the "Olympics" dataset. Count represents the number of pairs of distinct pla…
  5. Q5The following pseudocode is executed using the "Words" dataset. Based on the above data, answer the given subquestions.…
  6. Q6The following pseudocode is executed using the "Words" dataset. Based on the above data, answer the given subquestions.…
  7. Q7A palindrome is a sequence of characters which reads the same backward as forward, for example level and noon. The foll…
  8. Q8The following pseudocode is executed using the "Scores" dataset. What will Count represent at the end of execution?
  9. Q9The following pseudocode is executed using the "Scores" dataset. At the end of execution, B captures the minimum Mathem…
  10. Q10The following pseudocode is executed using the "Words" dataset. What will A represent at the end of execution?
  11. Q11The following pseudocode is executed using the "Scores" dataset. What will A represent at the end of execution?
  12. Q12The following pseudocode is executed using the "Scores" dataset. What will (A - B) represent at the end of execution?
  13. Q14The following pseudocode is executed using the "Olympics" dataset. It counts the number of pairs of players who have th…