Computational Thinking, Quiz 1
The following pseudocode is executed using the "Shopping Bills" dataset. At the end of execution, A captures the highest "Price" of an item purchased from "Big Bazaar". Choose the correct code fragment to complete the pseudocode.
A = 0while (Pile 1 has more cards) { Read the top card X in Pile 1 if (X.ShopName == "Big Bazaar") { temp = findItem(X) if (temp > A) { A = temp } } Move X to Pile 2}
Procedure findItem (Y) maxPrice = 0 while (Card Y has more items) { ******************** * Fill the code * ******************** } return (maxPrice)End findItemThe following pseudocode is executed using the "Shopping Bills" dataset. At the end of execution, **A** captures the highest "Price" of an item purchased from "Big Bazaar". Choose the correct code fragment to complete the pseudocode. A = 0 while (Pile 1 has more cards) { Read the top card X in Pile 1 if (X.ShopName == "Big Bazaar") { temp = findItem(X) if (temp > A) { A = temp } } Move X to Pile 2 } Procedure findItem (Y) maxPrice = 0 while (Card Y has more items) { ******************** * Fill the code * ******************** } return (maxPrice) End findItem A long word is defined as a word having at least 6 letters. The given pseudocode is used to find the average number of letters per word for long words from the "Words" dataset. Choose the correct code fragment to complete the pseudocode. letterCount = 0, wordCount = 0, avgLetPerWord = 0 While (Table 1 has more rows) { Read the first row X in Table 1 ******************** * Fill the code * ******************** } avgLetPerWord = letterCount / wordCount The following pseudocode is executed using the "Library" dataset. What will **count** represent at the end of execution? A = 0, count = 0 while (Pile 1 has more cards) { Read the top card X from Pile 1 if (X.Year > A) { A = X.Year } Move X to Pile 2 } while (Pile 2 has more cards) { Read the top card Y from Pile 2 if (Y.Year == A) { count = count + 1 } Move Y to Pile 1 }