Q22.The following pseudocode is executed using the "Shopping Bills" dataset. Procedure `findCommon` takes a pair of cards `X` and `Y` as input and returns True if the two cards share at least one common item; otherwise it returns False. What will `count` represent at the end of the execution?
```
count = 0
while(Pile 1 has more cards){
Read the top card X from Pile 1
Move the card X to Pile 2
while(Pile 1 has more cards){
Read the top card Y from Pile 1
if(X.ShopName != Y.ShopName and findCommon(X, Y)){
count = count + 1
}
Move the card Y to Pile 3
}
Move all the cards from Pile 3 to Pile 1
}
```
Save
Check
Details
Q22
16 Oct 2022
Q22.The following pseudocode is executed using the "Shopping Bills" dataset. Procedure `findCommon` takes a pair of cards `X` and `Y` as input and returns True if the two cards share at least one common item; otherwise it returns False. What will `count` represent at the end of the execution?
```
count = 0
while(Pile 1 has more cards){
Read the top card X from Pile 1
Move the card X to Pile 2
while(Pile 1 has more cards){
Read the top card Y from Pile 1
if(X.ShopName != Y.ShopName and findCommon(X, Y)){
count = count + 1
}
Move the card Y to Pile 3
}
Move all the cards from Pile 3 to Pile 1
}
```