Question 14
The procedure visitedShop(B) returns the list of names of customers who have visited shop B in the "Shopping Bills" dataset. Additionally, each customer must be represented exactly once in the returned list. The following pseudocode may have mistakes. Identify all such mistakes(if any). Assume that all statements not listed in the options below are free of errors. It is a Multiple Select Question (MSQ).
1 Procedure visitedShop(shop) 2 S = {} 3 while(Pile 1 has more cards){ 4 Read the top card X from Pile 1 5 if(X.ShopName == shop){ 6 if(not(checkMember(S, X.CustomerName))){ 7 S = [X.ShopName] ++ S 8 } 9 }10 Move X to Pile 211 }12 return(S)13 End visitedShop1415 Procedure checkMember(L, name)16 present = True17 foreach x in L{18 if(x == name){19 present = True20 exitloop21 }22 }23 return(present)24 End checkMemberLine 2: Incorrect initialization of S
Line 6: Incorrect condition to update S
Line 7: Incorrect update of S
Line 16: Incorrect initialization of present
No error