Quiz Space

Computational Thinking · End Term · 30 Apr 2023 · January 2023 term · Set QPF1-S2

Question 14: The procedure visitedShop(B) returns the list of names o…

Question 14

+5 marksOne or more correct options

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).

text
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 2
11 }
12 return(S)
13 End visitedShop
14
15 Procedure checkMember(L, name)
16 present = True
17 foreach x in L{
18 if(x == name){
19 present = True
20 exitloop
21 }
22 }
23 return(present)
24 End checkMember

Select all that apply.

  1. A

    Line 2: Incorrect initialization of S

  2. B

    Line 6: Incorrect condition to update S

  3. C

    Line 7: Incorrect update of S

  4. D

    Line 16: Incorrect initialization of present

  5. E

    No error

Show answer

Correct answers

  • A

    Line 2: Incorrect initialization of S

  • C

    Line 7: Incorrect update of S

  • D

    Line 16: Incorrect initialization of present

Question 14 of 25 in the IIT Madras BS Computational Thinking (Computational Thinking (CT)) End Term paper sat on 30 Apr 2023, in the January 2023 term (IIT M FOUNDATION ET1 EXAM QPF1 S2 30 Apr 2023). It carries 5 marks.

More questions from this paper

  1. Q1The following pseudocode is executed using the "Scores" dataset. What will count represent at the end of the execution?
  2. Q2The following pseudocode is executed using the "Words" dataset. What will B represent at the end of the execution?
  3. Q3The following pseudocode is executed using the "Words" dataset. The variable count stores the number of words which are…
  4. Q4The following pseudocode is executed using the "Library" dataset. At the end of the execution, N captures the name of a…
  5. Q5The following pseudocode is executed using the "Scores" dataset. What will B represent at the end of the execution?
  6. Q6The following pseudocode is executed using the "Olympics" dataset. What will dict represent at the end of the execution?
  7. Q7The following pseudocode is executed using the "Scores" dataset. What will first(D[i]) - last(D[i]) represent for a giv…
  8. Q8The following pseudocode is executed using the “Words” dataset. What will wordCount represent at the end of the executi…
  9. Q9Consider the following graph with six nodes. M is the 6 × 6 adjacency matrix corresponding to the graph below. Assume t…
  10. Q10Consider the procedure given below where A and B are two rows in the "Words" dataset. Let procedure getSomething(A) ret…
  11. Q11What will the value of S be at the end of the execution of the following pseudocode?
  12. Q12Let D be a dictionary. Choose the correct statement(s) about the dictionary D. It is a Multiple Select Question (MSQ).
  13. Q13reverse is a recursive procedure to reverse a list. Select the correct code fragment to complete the pseudocode given b…
  14. Q15The following pseudocode is executed using the "Shopping Bills" dataset. At the end of the execution, L stores the list…
  15. Q16stations is a list that contains the sequence of stations visited by a train from the "Trains" dataset. Each element in…
  16. Q17stations is a list that contains the sequence of stations visited by a train from the "Trains" dataset. Each element in…
  17. Q18trains is a list that contains information about trains associated with a station stn. Specifically, each element in th…
  18. Q19trains is a list that contains information about trains associated with a station stn. Specifically, each element in th…
  19. Q20trains is a list that contains information about trains associated with a station stn. Specifically, each element in th…
  20. Q21Let M be the adjacency matrix of the graph G given below. Consider the procedure given below. Based on above informatio…
  21. Q22Let M be the adjacency matrix of the graph G given below. Consider the procedure given below. Based on above informatio…
  22. Q23Let M be the adjacency matrix of the graph G given below. Consider the procedure given below. Based on above informatio…
  23. Q24What will evaluate(L1, L2) return?
  24. Q25How many times will the procedure evaluate be called, excluding the main call?