Graded Assignment - (Sep 2025 - CT - Qualifier)
The due date for submitting this assignment has passed. Due on 2025-12-10, 23:59 IST. You may submit any number of times before the due date. The final submission will be considered for grading.
Last Submitted: You have last submitted on: 2025-12-10, 07:23 IST
Note: ++++++++++++++++++++++++++++++++++
Question 1
reverse is a recursive procedure to reverse a list. Select the correct code fragment to complete the pseudocode given below. It is a Multiple Select Question (MSQ).
xxxxxxxxxx
1
Procedure reverse(L)
2
if(length(L) <= 1){
3
return(L)
4
}
5
*********************
6
* Fill the code *
7
*********************
8
End reverse
9
- return([last(L)] ++ reverse(init(L)))
- return([first(L)] ++ reverse(rest(L)))
- return([last(L)] ++ reverse(init(rest(L))) ++ [first(L)])
- return([first(L)] ++ reverse(init(rest(L))) ++ [last(L)])
- return([last(L)] ++ reverse(rest(init(L))) ++ [first(L)])
Status: Yes, the answer is correct. Score: 3
Accepted Answers:
- return([last(L)] ++ reverse(init(L)))
- return([last(L)] ++ reverse(init(rest(L))) ++ [first(L)])
- return([last(L)] ++ reverse(rest(init(L))) ++ [first(L)])
Question 2
What is the value of submissions?
- [ {“roll”: 12, “time”: 10:20, “score”: 80 }, {“roll”: 20, “time”: 11:23, “score”: 70 } ]
- [ {“roll”: 20, “time”: 11:23, “score”: 70 }, {“roll”: 12, “time”: 10:20, “score”: 80 } ]
- [ {“roll”: 12, “time”: 23:50, “score”: 95 }, {“roll”: 20, “time”: 23:53, “score”: 65 } ]
- [ {“roll”: 20, “time”: 23:53, “score”: 65 }, {“roll”: 12, “time”: 23:50, “score”: 95 } ]
Status: Yes, the answer is correct. Score: 4
Accepted Answers:
- [ {“roll”: 12, “time”: 23:50, “score”: 95 },
{“roll”: 20, “time”: 23:53, “score”: 65 } ]
Question 3
What does the variable submissions represent?
- The list of all the submissions made by the students sorted in the ascending order of time.
- The list of all the submissions made by the students sorted in the descending order of time.
- The list of the last submissions made by the students sorted in the ascending order of time.
- The list of the last submissions made by the students sorted in the descending order of time.
- The list of the first submissions made by the students sorted in the ascending order of time.
- The list of the first submissions made by the students sorted in the descending order of time.
Status: Yes, the answer is correct. Score: 4
Accepted Answers:
- The list of the last submissions made by the students sorted in the ascending order of time.
Question 4
Assume that reverse is a procedure that reverses a list. Which of the following statements returns the list of the first submissions made by the students sorted in the ascending order of time?
- getSubs(scores)
- reverse(getSubs(scores))
- getSubs(reverse(scores)))
- reverse(getSubs(reverse(scores)))
Status: Yes, the answer is correct. Score: 4
Accepted Answers:
- reverse(getSubs(reverse(scores)))
Question 5
outcomes is a list of strings that contains the information about the outcome of cricket matches played by India in a tournament. Assume that each element in the list is either “win” or “loss”. For example, if five matches have been played, then outcomes could look like this:
[“won”, “lost”, “lost”, “won”, “won”]
We call a list of outcomes a blank slate if the number of wins is equal to the number of losses. blankSlate is a procedure that accepts outcomes as input and returns True if it is a blank slate and False otherwise. Select the correct code fragment to complete the following pseudocode. It is a Multiple Select Question (MSQ).
xxxxxxxxxx
1
Procedure blankSlate(outcomes)
2
if(numeric(outcomes) == 0){
3
return(True)
4
}
5
else{
6
return(False)
7
}
8
End blankSlate
9
10
*********************
11
* Fill the code *
12
*********************
-
xxxxxxxxxx 1 Procedure numeric(L) 2 if(length(L) == 0){ 3 return(0) 4 } 5 if(last(L) == “won”){ 6 return(numeric(init(L)) + 1) 7 } 8 else{ 9 return(numeric(init(L)) − 1) 10 } 11 End numeric -
xxxxxxxxxx 1 Procedure numeric(L) 2 if(length(L) == 0){ 3 return (0) 4 } 5 if(last(L) == “won”){ 6 return(numeric(rest(L)) + 1) 7 } 8 else{ 9 return(numeric(rest(L)) − 1) 10 } 11 End numeric -
xxxxxxxxxx 1 Procedure numeric(L) 2 if(length(L) == 0){ 3 return(0) 4 } 5 if(first(L) == “won”){ 6 return(numeric(rest(L)) + 1) 7 } 8 else{ 9 return(numeric(rest(L)) − 1) 10 } 11 End numeric -
xxxxxxxxxx 1 Procedure numeric(L) 2 if(length(L) == 0){ 3 return(0) 4 } 5 if(first(L) == “won”){ 6 return(numeric(init(L)) + 1) 7 } 8 else{ 9 return(numeric(init(L)) − 1) 10 } 11 End numeric
Status: Yes, the answer is correct. Score: 4
Accepted Answers:
Procedure numeric(L) if(length(L) == 0){ return(0) } if(last(L) == “won”){ return(numeric(init(L)) + 1) } else{ return(numeric(init(L)) − 1) } End numericProcedure numeric(L) if(length(L) == 0){ return(0) } if(first(L) == “won”){ return(numeric(rest(L)) + 1) } else{ return(numeric(rest(L)) − 1) } End numeric
Question 6
matchThem is a recursive procedure that accepts players as argument and returns matches. Select the correct implementation of the procedure. It is a Multiple Select Question (MSQ).
-
xxxxxxxxxx 1 Procedure matchThem(players) 2 firstLast = [], middle = [] 3 if(length(players) == 2){ 4 return([players]) 5 } 6 else{ 7 firstLast = [first(players), last(players)] 8 middle = init(rest(players)) 9 return([firstLast] ++ matchThem(middle)) 10 } 11 End matchThem -
xxxxxxxxxx 1 Procedure matchThem(players) 2 firstLast = [], middle = [] 3 if(length(players) == 2){ 4 return(players) 5 } 6 else{ 7 firstLast = [first(players), last(players)] 8 middle = init(rest(players)) 9 return([firstLast] ++ matchThem(middle)) 10 } 11 End matchThem -
xxxxxxxxxx 1 Procedure matchThem(players) 2 firstLast = [], middle = [] 3 if(length(players) == 0){ 4 return([]) 5 } 6 else{ 7 firstLast = [first(players), last(players)] 8 middle = init(rest(players)) 9 return([firstLast] ++ matchThem(middle)) 10 } 11 End matchThem -
xxxxxxxxxx 1 Procedure matchThem(players) 2 firstLast = [], middle = [] 3 if(length(players) == 0){ 4 return([players]) 5 } 6 else{ 7 firstLast = [first(players), last(players)] 8 middle = init(rest(players)) 9 return([firstLast] ++ matchThem(middle)) 10 } 11 End matchThem
Status: Yes, the answer is correct. Score: 4
Accepted Answers:
Procedure matchThem(players) firstLast = [], middle = [] if(length(players) == 2){ return([players]) } else{ firstLast = [first(players), last(players)] middle = init(rest(players)) return([firstLast] ++ matchThem(middle)) } End matchThemProcedure matchThem(players) firstLast = [], middle = [] if(length(players) == 0){ return([]) } else{ firstLast = [first(players), last(players)] middle = init(rest(players)) return([firstLast] ++ matchThem(middle)) } End matchThem
Question 7
matchThem is a non-recursive procedure that accepts players as argument and returns matches. Select the correct implementation of the procedure.
-
xxxxxxxxxx 1 Procedure matchThem(players) 2 matches = [ ] 3 while(length(players) > 0){ 4 matches = matches ++ [[last(players), first(players)]] 5 players = rest(init(players)) 6 } 7 return(matches) 8 End matchThem -
xxxxxxxxxx 1 Procedure matchThem(players) 2 matches = [ ] 3 while(length(players) > 0){ 4 matches = matches ++ [[first(players), last(players)]] 5 players = rest(init(players)) 6 } 7 return(matches) 8 End matchThem -
xxxxxxxxxx 1 Procedure matchThem(players) 2 matches = [ ] 3 while(length(players) >= 0){ 4 matches = matches ++ [[first(players), last(players)]] 5 players = rest(init(players)) 6 } 7 return(matches) 8 End matchThem -
xxxxxxxxxx 1 Procedure matchThem(players) 2 matches = [ ] 3 while(length(players) > 0){ 4 matches = matches ++ [[first(players), last(players)]] 5 players = rest(players) 6 } 7 return(matches) 8 End matchThem 9
Status: Yes, the answer is correct. Score: 3
Accepted Answers:
Procedure matchThem(players) matches = [ ] while(length(players) > 0){ matches = matches ++ [[first(players), last(players)]] players = rest(init(players)) } return(matches) End matchThem
Question 8
What will be the value of S after executing the following pseudocode?
xxxxxxxxxx
1
P = { }
2
S = [ ]
3
P[0] = -1
4
P, S = DFS(A, P, S, 0)
- [0, 1, 2, 5, 3, 4]
- [0, 1, 4]
- [0, 1, 2, 3, 5, 4]
- [0, 3, 1, 4, 5]
Status: Yes, the answer is correct. Score: 4
Accepted Answers:
- [0, 1, 2, 3, 5, 4]
Question 9
What will be the value of nodes after executing the following pseudocode?
xxxxxxxxxx
1
P = { }
2
S = [ ], nodes = []
3
P[5] = -1
4
P, S = DFS(A, P, S, 5)
5
nodes = keys(P)
- [5, 2, 1, 0, 3, 4]
- [5, 2, 1, 4, 0, 3]
- [5, 2, 3, 0, 1, 4]
- Cannot be determined
Accepted Answers:
- Cannot be determined
Question 10
Assume that sort is a procedure that accepts a list of integers as input and returns a sorted list in ascending order. If 0 ≤ start ≤ 5, which of the following statements are true at the end of execution of the following pseudocode? It is a Multiple Select Question (MSQ).
xxxxxxxxxx
1
P = { }
2
S = [], nodes = []
3
P[start] = -1
4
P, S = DFS(A, P, S, start)
5
nodes = sort(keys(P))
- nodes is equal to [0, 1, 2, 3, 4, 5]
- S is equal to [0, 1, 2, 3, 4, 5]
- The value of nodes is independent of start
- The value of S is independent of start
- The graph is connected.
- The graph is not connected.
Status: Yes, the answer is correct. Score: 3
Accepted Answers:
- nodes is equal to [0, 1, 2, 3, 4, 5]
- The value of nodes is independent of start
- The graph is connected.
Question 11
Execute the following pseudocode
xxxxxxxxxx
1
P = { }
2
S = [ ]
3
P[3] = -1, parent = 0
4
P, S = DFS(A, P, S, 3)
5
B = createMatrix(6, 6)
6
foreach i in keys(P){
7
if(i != 3){
8
parent = P[i]
9
B[parent][i] = 1
10
}
11
}
Status: Yes, the answer is correct. Score: 4
Accepted Answers:



