Q4.The following pseudocode is executed using the Shopping bills dataset to find the number of bills with one of the top three total bill amounts. Choose the correct code block to complete the pseudocode.
```
FirstT = 0, SecondT = 0, ThirdT = 0
while (Pile 1 has more cards) {
Read the top card X from Pile 1
if (X.TotalBillAmount > FirstT) {
ThirdT = SecondT
SecondT = FirstT
FirstT = X.TotalBillAmount
}
if (X.TotalBillAmount < FirstT and X.TotalBillAmount > SecondT) {
ThirdT = SecondT
SecondT = X.TotalBillAmount
}
if (X.TotalBillAmount < SecondT and X.TotalBillAmount > ThirdT) {
ThirdT = X.TotalBillAmount
}
Move X to Pile 2
}
Count = 0
while (Pile 2 has more cards) {
Read the top card X from Pile 2
** Fill the code **
Move X to Pile 1
}
```
Save
Check
Details
Q4
15 Mar 2026
Q4.The following pseudocode is executed using the Shopping bills dataset to find the number of bills with one of the top three total bill amounts. Choose the correct code block to complete the pseudocode.
```
FirstT = 0, SecondT = 0, ThirdT = 0
while (Pile 1 has more cards) {
Read the top card X from Pile 1
if (X.TotalBillAmount > FirstT) {
ThirdT = SecondT
SecondT = FirstT
FirstT = X.TotalBillAmount
}
if (X.TotalBillAmount < FirstT and X.TotalBillAmount > SecondT) {
ThirdT = SecondT
SecondT = X.TotalBillAmount
}
if (X.TotalBillAmount < SecondT and X.TotalBillAmount > ThirdT) {
ThirdT = X.TotalBillAmount
}
Move X to Pile 2
}
Count = 0
while (Pile 2 has more cards) {
Read the top card X from Pile 2
** Fill the code **
Move X to Pile 1
}
```