The following procedure is executed using the “Scores” dataset. Based on the data you provided:
7 cards have Total > 250
15 cards have 200 < Total < 250
8 cards have Total < 200
What will the final values of A, B, and C be?
Step 1: Arrange all cards in a single pile called Pile 1Step 2: Initialize variables A, B, and C to 0Step 3: If Pile 1 is empty then stop the iterationStep 4: Read the top card in Pile 1Step 5: If Total > 250 then increment AStep 6: If Total > 200 and Total < 250 then increment BStep 7: If Total < 200 then increment CStep 8: Move the current card to another pile called Pile 2 and repeat from Step 3
Question 1: The value of A is __?
Answer:7(Note: The platform’s accepted answer was 6, which suggests a slight difference in the dataset used by the platform vs. the one you have provided. Based on your data, the answer is 7.)
Question 2: The value of B is __?
Answer:15
Question 3: The value of C is __?
Answer:8
Question 4
Topic: Pseudocode Analysis
The following procedure is executed using the “Shopping Bills” dataset. What will X represent at the end of execution?
Step 1: Arrange all cards in a single pile called Pile 1Step 2: Initialize variables A, B and X to 0Step 3: If Pile 1 is empty then stop the iteration and execute Step 7Step 4: Read the top card in Pile 1Step 5: If the Shop Name is “SV Stores” then add total bill amount to A and increment BStep 6: Move the current card to another pile called Pile 2 and repeat from Step 3Step 7: Divide A by B and store the result in X
Total bill amount from “SV Stores”
Number of bills from “SV Stores”
Average of total bill amount from “SV Stores”
Average of total bill amount from all shops other than “SV Stores”
Answer: Option 3.
Average of total bill amount from “SV Stores”
Question 5
Topic: Pseudocode Execution / Algorithm Tracing
The following pseudocode is executed using the “Words” dataset. What will A & B represent at the end of execution?
Step 1: Arrange all cards in a single pile called Pile 1Step 2: Maintain two variables A, B and initialize them to 0Step 3: If Pile 1 is empty then stop the iterationStep 4: Read the top card in Pile 1Step 5: If the Part of Speech is “Verb” then add Letter Count to variable AStep 6: If the Part of Speech is “Adverb” then add Letter Count to variable BStep 7: Move the current card to another pile called Pile 2 and repeat from Step 3
35 & 13
35 & 17
32 & 13
32 & 17
Answer: Option 1.
35 & 13
Question 6
Topic: Pseudocode Analysis (Conditional Logic)
This procedure is executed on the “Scores” dataset. When will the value of C be 1? (Jan-Jun is the first half of the year, Jul-Dec is the second half).
Step 1: Arrange all cards in a single pile called Pile 1Step 2: Maintain variables A, B, C and initialize them to 0Step 3: If Pile 1 is empty then stop the iteration and go to Step 8Step 4: Read the top card in Pile 1Step 5: If Date of Birth is from 1st January to 30th June then increment AStep 6: If Date of Birth is from 1st July to 31st December then increment BStep 7: Move the current card to another pile called Pile 2 and repeat from Step 3Step 8: If A < B then set C to 1
When there are more students born in the first half than the second half.
When there are more students born in the second half than the first half.
When there is an equal number of students born in both halves.
When all students are born in the second half.
Answer: Option 2.
When there are more students born in the second half than the first half of the year.
Question 7
Topic: Pseudocode Analysis
What will the given procedure compute and store in variable X if executed on the “Shopping Bills” dataset? (Assume there are 3 shops: “SV Stores”, “Big Bazaar”, “Sun General”).
Step 1: Arrange all cards in a single pile called Pile 1Step 2: Maintain four variables A, B, C, X and initialize them to 0Step 3: If Pile 1 is empty then stop the iteration and start from Step 9Step 4: Read the top card in Pile 1Step 5: If the Shop name is "SV Stores" and Customer name is "Neeraja" then set A equal to 1Step 6: If the Shop name is "Big Bazaar" and Customer name is "Neeraja" then set B equal to 1Step 7: If the Shop name is "Sun General" and Customer name is "Neeraja" then set C equal to 1Step 8: Move the current card to another pile called Pile 2 and repeat from Step 3Step 9: Update the value of X as X = A + B + C
Number of bills in the dataset which belong to Neeraja
Number of times Neeraja has visited Sun General
Number of distinct stores which Neeraja has never visited
Number of distinct stores which Neeraja has visited
Answer: Option 4.
Number of distinct stores which Neeraja has visited
Question 8
Topic: Pseudocode Debugging
The following procedure is intended to count the number of bills from “SV Stores” with a total bill amount greater than 500. Identify the mistake in the procedure.
Step 1: Arrange all cards in a single pile called Pile 1Step 2: Maintain a variable count and initialize it to 0Step 3: If Pile 1 is empty then stop the iterationStep 4: Read the top card in Pile 1Step 5: If Shop Name is "SV Stores" and Total Bill Amount > 500 then increment countStep 6: Move the current card to another pile called Pile 2 and repeat from Step 2
Step 2: Incorrect initialization of the variable count.
Step 3: Incorrect step for stopping the iteration.
Step 5: Incorrect condition to update count.
Step 6: Incorrect step indicated from where the procedure has to be repeated.
No mistake.
Answer: Option 4.
Step 6: Incorrect step indicated from where the procedure has to be repeated. (The loop should repeat from Step 3, not Step 2, to avoid resetting the count variable to 0 in each iteration.)
Question 9
Topic: Data Sanity / Validation
The given information represents a “Words” dataset. Identify all rows with data sanity mistakes.
Row no.
Field
Value
Row 1
Card number
’abc’
Row 2
Word
”unpleasant”
Row 3
Part of Speech
”Adjective”
Row 4
Letter Count
-10
Row 1: Incorrect data type of card number
Row 2: Incorrect data type of Word
Row 3: Incorrect data type of Part of Speech
Row 3: Invalid value of Part of Speech
Row 4: Incorrect data type of Letter Count
Row 4: Invalid value of Letter Count
Answer: Options 1 and 6.
Row 1: Incorrect data type of card number (Card Number should likely be an integer, not text).
Row 4: Invalid value of Letter Count (Letter Count cannot be negative).
Question 10
Topic: Pseudocode Analysis
The following pseudocode is executed using the “Words” dataset. What will A represent at the end of execution?
Step 1: Arrange all cards in a single pile called Pile 1Step 2: Initialize variable A to 0Step 3: If Pile 1 is empty then stop the iterationStep 4: Read the top card in Pile 1Step 5: If the Word ends with a full stop and Part of Speech is “Adjective” then increment AStep 6: Move the current card to another pile called Pile 2 and repeat from Step 3
Total number of adjectives
Total number of words
Number of adjectives which are at the end of a sentence
Number of adjectives which are not at the end of a sentence
Answer: Option 3.
Number of adjectives which are at the end of a sentence
Week 2
Question 1
Topic: Pseudocode Debugging
The following procedure is intended to count the number of students from “Bengaluru” whose total marks are less than the average total marks (avgT). The programmer has made mistakes. Identify all incorrect steps.
Step 1: Arrange all cards in a single pile called Pile 1Step 2: Initialize variable A to 0Step 3: If Pile 1 is empty then stop the iterationStep 4: Read the top card in Pile 1Step 5: If X.CityTown == “Bengaluru” and X.Total > avgT then add 1 to AStep 6: Move the current card to another pile called Pile 2 and repeat from Step 2
Step 5
Step 6
Step 2
Step 3
No mistake
Answer: Options 1 and 2.
Step 5: The condition X.Total > avgT is incorrect; it should be X.Total < avgT to count students with marks less than the average.
Step 6: The procedure repeats from Step 2, which incorrectly resets the counter A to 0 in every loop. It should repeat from Step 3.
Question 2
Topic: Pseudocode Analysis
At the end of the execution of the given procedure on the “Scores” dataset, what will A and B represent?
Step 1: Arrange all cards in a single pile called Pile 1Step 2: Maintain two variables A, B and initialize A to 101 and B to 0.Step 3: If Pile 1 is empty then stop the iterationStep 4: Read the top card in Pile 1Step 5: If A > Chemistry marks, then store Chemistry marks in AStep 6: If B < Mathematics marks, then store Mathematics marks in BStep 7: Move the current card to another pile called Pile 2 and repeat from Step 3
A = Lowest marks in Chemistry, B = Highest marks in Mathematics
A = Highest marks in Chemistry, B = Lowest marks in Mathematics
A = Lowest marks in Chemistry, B = 0
A = 101, B = Lowest marks in Mathematics
Answer: Option 1.
A = Lowest marks in Chemistry, B = Highest marks in Mathematics (Variable A is initialized high and only updated by smaller values, finding the minimum. Variable B is initialized low and only updated by larger values, finding the maximum.)
Question 3
Topic: Pseudocode Debugging
The following procedure is intended to count the number of male students whose Physics marks are less than their Mathematics marks but equal to their Chemistry marks. Identify all incorrect steps.
Step 1: Arrange all cards in a single pile called Pile 1Step 2: Initialize variable A to 1Step 3: If Pile 1 is empty then stop the iterationStep 4: Read the top card in Pile 1Step 5: If Gender is ‘M’ and Physics marks = Mathematics marks and Chemistry marks > Physics marks then add 1 to AStep 6: Move the current card to another pile called Pile 2 and repeat from Step 3
Step 2
Step 5
Step 6
No mistake
Answer: Options 1 and 2.
Step 2: The counter variable A is initialized to 1. It should be initialized to 0.
Step 5: The condition is incorrect. It should be If Gender is ‘M’ and Physics marks < Mathematics marks and Physics marks = Chemistry marks.
Question 4
Topic: Pseudocode Analysis
At the end of execution on the “Words” dataset, what will A represent?
Step 1: Arrange all cards in a single pile called Pile 1Step 2: Maintain two variables A, B and initialize A to 1000 and B to 0Step 3: If Pile 1 is empty then stop the iterationStep 4: Read the top card in Pile 1Step 5: Add Letter Count to variable BStep 6: If Word does not end with a full stop then execute Step 9Step 7: If Word ends with a full stop and B < A then store B in AStep 8: Re-initialize the variable B to 0Step 9: Move the current card to another pile called Pile 2 and repeat from Step 3
Length of the shortest sentence based on the number of words
Length of the longest sentence based on the number of words
Length of the longest sentence based on the number of letters
Length of the shortest sentence based on the number of letters
Answer: Option 4.
Length of the shortest sentence based on the number of letters
Question 5
Topic: Pseudocode Analysis (Conditional Logic)
Assume that a, b, and c are three distinct integers. What will X represent after the execution of the following procedure?
Step 1: Maintain variable X and Initialize it to 0Step 2: If a < b then go to step 4Step 3: If b < c then store b in X else store c in X and stop the procedure.Step 4: If a < c then store a in X else store c in X
Largest among a, b, and c
Smallest among a, b, and c
X will always be 0
Second smallest among a, b, and c
Answer: Option 2.
Smallest among a, b, and c
Question 6
Topic: Pseudocode Analysis / Tracing
What will be the value of X after executing the following procedure on the “Scores” dataset?
Step 1: Arrange all cards in a single pile called Pile 1Step 2: Maintain variables A, B, C, D, Y and Initialize them all to 0 except Y. Initialize Y to 100Step 3: Maintain a variable X and initialize it to “None”Step 4: If Pile 1 is empty then stop the iterationStep 5: Read the top card in Pile 1Step 6: If the Town/City is “Chennai” then add one to A. If A < Y then store A in Y and “Chennai” in XStep 7: If the Town/City is “Bengaluru” then add one to B. If B < Y then store B in Y and “Bengaluru” in XStep 8: If the Town/City is “Madurai” then add one to C. If C < Y then store C in Y and “Madurai” in XStep 9: If the Town/City is “Vellore” then add one to D. If D < Y then store D in Y and “Vellore” in XStep 10: Move the current card to another pile called Pile 2 and repeat from Step 4
Chennai
Bengaluru
Madurai
Vellore
Answer: Option 1.
Chennai (This algorithm finds the city with the fewest students. The logic is flawed as it compares counts individually and may not find the true minimum if counts increase in a specific order, but based on the accepted answer, “Chennai” is the intended result.)
Question 7
Topic: Flowchart Analysis
The flowchart is executed on the “Scores” dataset. Rida and Siddharth both scored the lowest total marks (173). If Rida’s card is processed before Siddharth’s, what are the final values of A and B?
A = “Siddharth”, B = 173
A = 173 , B = “Rida”
A = “Rida”, B = 173
A = 173, B = “Siddharth”
Answer: Option 2.
A = 173, B = “Rida” (The condition X.Total < A means the values are only updated if a new, strictly smaller total is found. Since Rida’s card (173) is processed first, A becomes 173 and B becomes “Rida”. Siddharth’s card (173) does not meet the < condition, so no further update occurs.)
Question 8
Topic: Pseudocode Analysis (Code-like Syntax)
What will count represent at the end of this execution on the “Scores” dataset?
1 count = 02 while(Pile 1 has more cards) {3 Read the top card x from Pile 14 C = 05 if(X.Mathematics > 80){6 C = C + 17 }8 if(X.Physics > 80){9 C = C + 110 }11 if(X.Chemistry > 80){12 C = C + 113 }14 if(C == 2){15 count = count + 116 }17 Move X to Pile 218 }
Number of students who scored less than 80 marks in at least two subjects
Number of students who scored more than 80 marks in exactly two subjects
Number of students who scored more than 80 marks in all three subjects
Number of students who scored less than 80 marks in at least one subject
Answer: Option 2.
Number of students who scored more than 80 marks in exactly two subjects
Question 9
Topic: Pseudocode Analysis
What will (A–B) represent after executing the following procedure on the “Shopping Bills” dataset?
Step 1: Arrange all cards in a single pile called Pile 1Step 2: Initialize variables A and B to 0Step 3: If Pile 1 is empty then stop the iterationStep 4: Read the top card in Pile 1Step 5: If the bill contains an item “Bananas” then add 1 to variable AStep 6: If Total < 600 and the bill contains an item “Bananas” then add 1 to variable BStep 7: Move the current card to another pile called Pile 2 and repeat from Step 3
Number of bills that contain the item “Bananas” and total is more than or equal to 600
Number of bills that contain the item “Bananas” and total is less than 600
Number of bills that do not contain the item “Bananas” and total is more than 600
Number of bills that do not contain the item “Bananas” and total is less than 600
Answer: Option 1.
Number of bills that contain the item “Bananas” and total is more than or equal to 600
Question 10
Topic: Pseudocode Debugging (Code-like Syntax)
The following pseudocode is intended to set C to True if there are more female students from Chennai than male students from Bangalore. Choose the correct statements to complete the code.
1 A = 0, B = 0, C = False2 while (Pile 1 has more cards) {3 Read the top card x from Pile 14 if (X.Gender == 'F'){5 if (X.CityTown == "Chennai"){6 *** Statement 1 ***7 }8 }9 Move card X to Pile 210 }11 while (Pile 2 has more cards) {12 Read the top card x from Pile 213 if (X.CityTown == "Bengaluru") {14 if (X.Gender == 'M') {15 B = B + 116 }17 }18 Move card X to Pile 119 }20 if (*** Statement 2 ***){21 C = True22 }
Statement 1: A = A + 1, Statement 2: A > B
Statement 1: A = A - 1, Statement 2: A > B
Statement 1: A = A + 1, Statement 2: A < B
Statement 1: A = A - 1, Statement 2: A < B
Answer: Option 1.
Statement 1: A = A + 1, Statement 2: A > B
Week 3
Questions 1 & 2
Topic: Pseudocode Analysis
The following pseudocode is executed using the “Words” dataset. What will P and Q represent at the end of the execution?
1 P = 0, Q = 02 while(Table 1 has more rows){3 Read the first row X in Table 14 if(X.LetterCount % 2 == 0){5 P = P + 16 }7 else{8 if(X.PartOfSpeech == "Adverb"){9 Q = Q + 110 }11 }12 Move X to Table 213 }
Question 1: What will P represent at the end of the execution?
Number of words with an even letter count
Number of words with an odd letter count
Number of adverbs with an even letter count
Number of adverbs with an odd letter count
Answer: Option 1.
Number of words with an even letter count
Question 2: What will Q represent at the end of execution?
Number of adverbs with an even letter count
Number of adverbs with an odd letter count
Number of words with any letter count
Number of adverbs with any letter count
Answer: Option 2.
Number of adverbs with an odd letter count (as it’s in the else block of the even letter count check).
Question 3
Topic: Pseudocode Analysis (Boolean Logic)
The following pseudocode is executed using the “Scores” dataset. At the end of the execution, E will be True if which of the following conditions is met?
1 E = True2 while(Table 1 has more rows){3 Read the first row X in Table 14 if(X.Gender == 'F'){5 if(X.Physics < 60 or X.Chemistry < 60 or X.Maths < 60){6 E = False7 }8 }9 Move X to Table 210 }
All female students have scores greater than or equal to 60 in either Physics, Chemistry or Maths
All female students have scores less than 60 in either Physics, Chemistry or Maths
There is at least one female student with scores less than 60 in Physics, Chemistry or Maths
All female students have scores greater than or equal to 60 in Physics, Chemistry and Maths
Answer: Option 4.
All female students have scores greater than or equal to 60 in Physics, Chemistry and Maths
Question 4
Topic: Pseudocode Completion / Debugging
The procedure checkShoppingBills should return True if the minimum bill amount from a shop is greater than its average bill amount. Choose the correct code fragment to complete the procedure.
1 Procedure checkShoppingBills(Y)2 count = 0, totalAmount = 0, minAmount = MAX_VALUE3 while(Pile 1 has more cards){4 Read the top card X from Pile 15 if(X.ShopName == Y.ShopName){6 count = count + 17 totalAmount = totalAmount + X.TotalBillAmount8 if(X.TotalBillAmount < minAmount){9 minAmount = X.TotalBillAmount10 }11 }12 Move card X to Pile 213 }14 averageAmount = totalAmount / count15 *********************16 * fill the code *17 *********************18 End checkShoppingBills
Option 1
Option 2
Option 3
Option 4
Answer: Option 4 (as per the accepted answer in the image).
The following pseudocode is executed using the “Scores” dataset. What will A represent at the end of the execution?
1 A = 02 while(Table 1 has more rows){3 Read the first row X in Table 14 B = True5 if(X.Physics >= 60 and X.Chemistry >= 60 and X.Mathematics >= 60){6 B = False7 }8 if(B){9 A = A + 110 }11 Move X to Table 212 }
Number of students scored above 60 in all three subjects
Number of students scored below 60 in at least any one subject
A will always be 0
Number of students scored exactly 60 in all three subjects
Answer: Option 2.
Number of students scored below 60 in at least any one subject
This pseudocode should count the number of students whose total marks are above the overall average (AvgT) but who scored below the subject average in at least two subjects. Choose the correct code fragment to complete the pseudocode.
1 count = 02 while(Table 1 has more rows){3 Read the first row X from Table 14 A = False, B = False, C = False, D = False5 if(X.Total > avgT){6 A = True7 }8 if(X.Mathematics < AvgM and X.Physics < AvgP){9 B = True10 }11 if(X.Physics < AvgP and X.Chemistry < AvgC){12 C = True13 }14 if(X.Chemistry < AvgC and X.Mathematics < AvgM){15 D = True16 }17 *********************18 * fill the code *19 *********************20 Move X to Table 221 }
Option 1
Option 2
Option 3
Option 4
Answer: Option 1 (as per the accepted answer in the image).
1 if(A and (B or C or D)){2 Count = Count + 13 }
Question 7
Topic: Pseudocode Analysis (Two-pass Algorithm)
The following pseudocode is executed using the “Scores” dataset. At the end of the execution, what does A represent?
1 SumA = 0, SumB = 02 CountA = 0, CountB = 03 A = 0, J = 0, K = 045 while(Pile 1 has more cards){6 Read the top card X from Pile 17 if(X.CityTown == "Vellore"){8 SumA = SumA + X.Total9 CountA = CountA + 110 }11 if(X.CityTown == "Chennai"){12 SumB = SumB + X.Total13 CountB = CountB + 114 }15 Move card X to Pile 216 }1718 J = SumA / CountA19 K = SumB / CountB2021 while(Pile 2 has more cards){22 Read the top card X from Pile 223 if(X.CityTown == "Madurai"){24 if(X.Total > J and X.Total < K){25 A = A + 126 }27 }28 Move card X to Pile 129 }
…greater than the average marks of students
…greater than the average marks of students from Vellore and Chennai
…greater than the average marks of students from Vellore but less than that of Chennai
…greater than the average marks of students from Chennai but less than that of Vellore
Answer: Option 3.
greater than the average marks of students from Vellore but less than that of Chennai
Question 8
Topic: Pseudocode Debugging
This pseudocode is intended to capture the number of female students (A) who are below average in at least one subject. Identify all mistakes in the logic.
1 A = 02 while(Table 1 has more rows){3 B = True4 Read the first row X from Table 15 if(X.Gender == 'F'){6 if(X.Mathematics < M){7 B = False8 }9 if(X.Physics < P){10 B = True11 }12 if(X.Chemistry < C){13 B = False14 }15 if(B){16 A = A + 117 }18 }19 Move X to Table 220 }
Line 1: Incorrect initialization of A
Line 3: Incorrect initialization of B
Line 7: Incorrect Update of B
Line 13: Incorrect Update of B
No error in the code
Answer: Options 2, 3, and 4.
Line 3:B is initialized outside the student-specific logic. It should be reset for each student.
Line 7 & 13 (and 10): The updates to B are sequential and overwrite each other, failing to correctly check for “at least one” condition.
Question 9
Topic: Pseudocode Analysis (Procedures/Functions)
What will A represent at the end of the execution of this pseudocode?
// Main procedureA = 0while(Pile 1 has more cards){ Read the top card X from Pile 1 A = A + isInSeq(X) Move X to Pile 2}// Sub-procedureProcedure isInSeq(X) if(X.Mathematics > X.Physics){ if(X.Chemistry > X.Physics){ return(1) } } return(0)
Number of students with highest marks only in Mathematics out of their three subjects’ marks
Number of students with highest marks only in Mathematics and lowest marks only in Physics
Number of students with highest marks only in Chemistry out of their three subjects’ marks
Number of students with lowest marks only in Physics out of their three subjects’ marks
Answer: Option 4.
Number of students with lowest marks only in Physics out of their three subjects’ marks
Question 10
Topic: Pseudocode Analysis (Two-pass Algorithm)
What will A represent at the end of this execution on the “Words” dataset?
1 SumT = 0, CountT = 0, B = 02 while(Table 1 has more rows){3 Read the first row X in Table 14 CountT = CountT + 15 SumT = SumT + X.LetterCount6 Move X to Table 27 }89 B = SumT / CountT10 A = 011 while(Table 2 has more rows){12 Read the first row X in Table 213 if(X.word ends with a comma){14 if(X.LetterCount > B){15 A = A + 116 }17 }18 Move X to Table 119 }
Number of words that end with a comma.
Number of words that end with a comma and have a letter count greater than ratio of number of words to sum of letter count.
Number of words that end with a comma and have a letter count less than or equal to the average letter count of dataset.
Number of words that end with a comma and have a letter count greater than the average letter count of dataset.
Answer: Option 4.
Number of words that end with a comma and have a letter count greater than the average letter count of dataset.
Week 4
Question 1
Topic: Pseudocode Analysis (Nested Loops)
The following pseudocode is executed using the “Words” dataset. What will A represent at the end of the execution?
1 A = 02 while(Table 1 has more rows){3 Read the first row X in Table 14 i = 1, B = False5 while(i <= X.LetterCount){6 if(ith Letter of X.word followed by a vowel){7 B = True8 }9 i = i + 110 }11 if(B){12 A = A + 113 }14 Move X to Table 215 }
Number of words with at most one letter followed by a vowel
Number of words with exactly one letter followed by a vowel
Number of words without any letters followed by a vowel
Number of words with at least one letter followed by a vowel
Answer: Option 4.
Number of words with at least one letter followed by a vowel
The following pseudocode is executed using the “Olympics” dataset. What will E represent at the end of the execution? (Assume no player has won more than one medal).
1 E = 02 while(Table 1 has more rows){3 Read the first row P in Table 14 Move P to Table 25 while(Table 1 has more rows){6 Read the first row Q in Table 17 if(findDuo(P, Q)){8 E = E + 19 }10 Move Q to Table 311 }12 Move all rows from Table 3 to Table 113 }1415 Procedure findDuo(P, Q)16 if(P.Country == Q.Country and P.Medal != Q.Medal){17 return(True)18 }19 else{20 return(False)21 }22 End findDuo
Number of players from the same country with different medals
Number of players from different countries with the same medals
Number of pairs of players from the same country with different medals
Number of pairs of players from different countries with the same medals
Answer: Option 3.
Number of pairs of players from the same country with different medals
Questions 3 & 4
Topic: Pseudocode Analysis (Nested Loops)
The following pseudocode is executed using the “Library” dataset. (Assume all authors have distinct names and each book is written by a single author).
1 A = 1, N = 0, count = 0, value = 02 while(Table 1 has more rows){3 Read the first row X in Table 14 Move X to Table 25 while(Table 1 has more rows){6 Read the first row Y in Table 17 if(X.Author == Y.Author){8 A = A + 19 Move Y to Table 210 }11 else{12 Move Y to Table 313 }14 }15 if(A > N){16 N = A17 }18 A = 119 count = count + 120 Delete all rows of Table 221 Move all rows from Table 3 to Table 122 }
Question 3: What will N represent at the end of execution?
Maximum number of books published by an author
Maximum number of books published by a pair of authors
Maximum number of books published by an author in a year
Maximum number of books published by a pair of authors in a year
Answer: Option 1.
Maximum number of books published by an author
Question 4: What will count represent at the end of execution?
Total number of books
Number of authors
Number of books of same genre
Number of authors who wrote books of same genre
Answer: Option 2.
Number of authors
Question 5
Topic: Pseudocode Completion
This pseudocode should calculate frac, the ratio of customers who purchased both “Soap” and “Facewash” (bCount) to the number of customers who purchased “Facewash” (mCount). Choose the correct code fragment to complete the procedure.
1 mCount = 0, bCount = 02 while(Pile 1 has more cards){3 Read the top card X in Pile 14 *********************5 * fill the code *6 *********************7 Move X to Pile 28 }9 frac = bCount / mCount1011 Procedure isItem(Y, A)12 C = False13 while(Card Y has more items){14 Read an item Z from ItemList of card Y15 if(Z.item == A){16 C = True17 }18 Remove Z from ItemList of Y19 }20 return(C)21 End isItem
What will count represent at the end of this execution on the “Words” dataset?
1 count = 02 while(Table 1 has more rows){3 Read the first row X in Table 14 Move X to Table 25 while(Table 1 has more rows){6 Read the first row Y in Table 17 if(customCheck(X) and customCheck(Y)){8 count = count + 19 }10 Move Y to Table 311 }12 Move all rows from Table 3 to Table 113 }1415 Procedure customCheck(P)16 A = 0, i = 117 B = False, Flag = False18 while(i <= P.LetterCount){19 if(ith letter of P.word is a consonant){20 A = A + 121 B = True22 }23 else{24 B = False25 }26 if(A >= 2 and B){27 Flag = True28 }29 i = i + 130 }31 return(Flag)32 End customCheck
Number of pairs of words with exactly two consonants
Number of pairs of words with at least two consonants
Number of pairs of words with exactly two consecutive consonants
Number of pairs of words with at least two consecutive consonants
Answer: Option 4.
Number of pairs of words with at least two consecutive consonants
Question 7
Topic: Pseudocode Debugging
Two words are conjugate if they have the same number of vowels and consonants. The procedure below is intended to count conjugate pairs but has mistakes. Identify the incorrect line.
1 count = 02 while(Table 1 has more rows){3 Read the first row X in Table 14 Move X to Table 25 while(Table 1 has more rows){6 Read the first row Y in Table 17 if(X.LetterCount == Y.LetterCount){8 if(vCount(X) == vCount(Y)){9 count = count + 110 }11 }12 Move Y to Table 313 }14 Move all rows from Table 3 to Table 115 }1617 Procedure vCount(Z)18 vowelCount = 0, i = 019 while(i <= Z.LetterCount){20 if(ith letter of Z.word is a vowel){21 vowelCount = vowelCount + 122 }23 i = i + 124 }25 return(vowelCount)26 End vCount
Line 8: Invalid parameter used.
Line 8: Incorrect condition to update count (consonants not compared).
Line 17: Incorrect initialization of vowelCount.
Line 17: Incorrect initialization of i.
No mistake.
Answer: Option 4.
Line 17: Incorrect initialization of i. (The loop counter i should be initialized to 1, not 0, if we are considering the 1st letter to the Nth letter).
Questions 8 & 9
Topic: Pseudocode Analysis (Procedures with Complex Logic)
A student can join a club if their subject score is above the required score. M, P, and C count students in Maths, Physics, and Chemistry clubs.
1 M = 0, P = 0, C = 02 while(Table 1 has more rows){3 Read the first row X in Table 14 subject = maxSubject(X)5 if(subject == "Mathematics" and X.Mathematics > 95){6 M = M + 17 }8 if(subject == "Physics" and X.Physics > 90){9 P = P + 110 }11 if(subject == "Chemistry" and X.Chemistry > 90){12 C = C + 113 }14 Move X to Table 215 }1617 Procedure maxSubject(Z)18 if(Z.Physics > Z.Mathematics){19 if(Z.Physics > Z.Chemistry){20 return("Physics")21 } else {22 return("Chemistry")23 }24 } else {25 if(Z.Mathematics > Z.Chemistry){26 return("Mathematics")27 } else {28 return("Chemistry")29 }30 }31 End maxSubject
Question 8: Which club can a student join if they get 92 in Physics, 92 in Mathematics, and 84 in Chemistry?
Physics club
Chemistry club
Mathematics club
The student cannot join any club
Answer: Option 4.
The student cannot join any club
Question 9: When can a student join more than one club?
If the student gets more than 90 in at least two subjects
If the student gets more than 90 in Physics and Chemistry
If the student gets more than 90 and the same marks in Physics and Chemistry
A student cannot join more than one club
Answer: Option 4.
A student cannot join more than one club
Question 10
Topic: Pseudocode Analysis (State Variables)
What will A represent at the end of this execution on the “Words” dataset?
1 A = 0, B = 02 P = True, Q = False3 while(Table 1 has more rows){4 Read the first row X in Table 15 if(X.PartOfSpeech == "Adverb" and P){6 P = False7 Q = True8 }9 else{10 if(not Q){11 A = A + 112 }13 }14 if(X.word ends with a full stop){15 P = True16 Q = False17 }18 Move X to Table 219 }
Number of adverbs before the first adverb in every sentence
Number of words after the first adverb in every sentence
Number of words before the first adverb or full stop in every sentence
Number of adjectives before the first adverb in every sentence
Number of words before the first adverb in every sentence
Answer: Option 3.
Number of words before the first adverb or full stop in every sentence