Quiz Space

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

Question 17: stations is a list that contains the sequence of station…

Question 17

+4 marksOne correct option

stations is a list that contains the sequence of stations visited by a train from the "Trains" dataset. Each element in stations is a pair: [Name, Distance], the first entry is the name of the station, while the second entry is the distance of this station from the first station in the list.
maxDist is a procedure that accepts stations as a parameter and returns the names of a pair of consecutive stations which have the longest distance between them on this route. Complete the following procedure.

text
1 Procedure maxDist(stations)
2 pair = ["None", "None"]
3 max = 0, diff = 0
4 prev = first(stations)
5 foreach x in rest(stations){
6 diff = last(x) - last(prev)
7 *************************
8 * Fill the code *
9 *************************
10 prev = x
11 }
12 return(pair)
13 End maxDist

Based on the above data, answer the given subquestions.

There may be multiple pairs having the same maximum distance. If we wish to find a pair of stations closest to the last station in the list, which of the following is the correct code fragment?

  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • B

Question 17 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 4 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. Q14The procedure visitedShop(B) returns the list of names of customers who have visited shop B in the "Shopping Bills" dat…
  15. Q15The following pseudocode is executed using the "Shopping Bills" dataset. At the end of the execution, L stores the list…
  16. Q16stations 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?