MOCK 2 - Quiz 2 - (Sep 2025 - CT - Qualifier)
This assignment will not be graded and is only for practice.
Question 1
Let L be a non-empty list of integers, and D be a non-empty dictionary which are given below:
**
L** = [8, -4, 10, 4, -6]
D = {1: {āNameā: āJohnā, āAgeā: 12, āGenderā: āMā}}
Match the following expressions on the left side with the appropriate values on the right side.

- a - (5), b - (5), c - (6), d - (3), e - (2), f - (6)
- a - (5), b - (4), c - (1), d - (1), e - (2), f - (3)
- a - (5), b - (4), c - (6), d - (1), e - (1), f - (6)
- a - (5), b - (5), c - (1), d - (1), e - (2), f - (3)
- a - (5), b - (6), c - (1), d - (1), e - (2), f - (3)
Question 2
What will the value of outList be at the end of the given pseudocode?
xxxxxxxxxx
1
N = [1, 2, 3, 4, 5, 6, ....., 49, 50]
2
A = someList(N)
3
B = someList(rest(rest(N)))
4
outList = []
5
foreach Y in A {
6
foreach Z in B {
7
if(Z == Y){
8
outList = outList ++ [Y]
9
}
10
}
11
}
12
13
Procedure someList(X)
14
outlist = [ ], newList = X
15
while(length(newList) > 0){
16
outlist = outlist ++ [first(newList)]
17
newList = rest(rest(newList))
18
}
19
return(outlist)
20
End someList
- [1, 2, 3, 4, 5, 6, ā¦, 49, 50]
- [1, 3, 5, 7, ā¦, 49]
- [2, 4, 6, 8, ā¦,50]
- [3, 5, 7, ā¦, 49]
Question 3
Two trains are called āOpposite Trainsā if they stop at the same set of stations but in the reverse order. isOpposite(N1, N2) returns True if trains with train numbers N1 and N2 are āOpposite Trainsā and False otherwise. trains is a dictionary with train number as key mapped to a list of stations which that train runs through. For example, trains = { 12281: [āBhubaneswarā, āBalasoreā, āAdraā, āVaranasiā, āKanpurā, āNew Delhiā],ā¦}.
In this example, the train with train number 12281 starts from Bhubaneswar and reaches New Delhi via Balasore, Adra, Varanasi, and Kanpur in the order. Choose the correct code fragments to complete the procedure. It is a Multiple Select Question (MSQ).
xxxxxxxxxx
1
Procedure isOpposite(N1, N2)
2
L1 = trains[N1]
3
L2 = trains[N2]
4
if(length(L1) != length(L2)){
5
return(False)
6
}
7
while(L1 != [ ] and first(L1) == last(L2)){
8
L1 = rest(L1)
9
L2 = init(L2)
10
}
11
*******************
12
* Fill the code *
13
*******************
14
End isOpposite
-
xxxxxxxxxx 1 if(L1 == [ ]){ 2 return(True) 3 } 4 else{ 5 return(False) 6 } -
xxxxxxxxxx 1 if(L1 == [ ]){ 2 return(False) 3 } 4 else{ 5 return(True) 6 } -
xxxxxxxxxx 1 if(L2 == [ ]){ 2 return(False) 3 } 4 else{ 5 return(True) 6 } -
xxxxxxxxxx 1 if(L2 == [ ]){ 2 return(True) 3 } 4 else{ 5 return(False) 6 }
Question 4
Let trains be a dictionary with train number as key mapped to a list of stations which that train runs through. For example,
trains = { 12281 : [āBhubaneswarā,āBalasoreā, āAdraā, āVaranasiā, āKanpurā, āNew Delhiā], ā¦}.
In this example, the train with train number 12281 starts from Bhubaneswar and reaches New Delhi via Balasore, Adra, Varanasi, and Kanpur.
At the end of execution of the code below, L stores the names of stations through which the maximum number of trains pass. Choose the correct fragment to complete the pseudocode.
xxxxxxxxxx
1
stns = { },
2
N = 0, L = [ ]
3
foreach X in keys(trains){
4
stns = updateDictionary(stns, X)
5
}
6
7
foreach Y in keys(stns){
8
**********************
9
* Fill the code *
10
**********************
11
}
12
13
Procedure updateDictionary(D, Z)
14
foreach A in trains[Z]{
15
if(not isKey(D, A)){
16
D[A] = 1
17
}
18
else{
19
D[A] = D[A] + 1
20
}
21
}
22
return(D)
23
End updateDictionary
-
xxxxxxxxxx 1 if(stns[Y] == N){ 2 L = L ++ [Y] 3 } 4 if(stns[Y] > N){ 5 L = [Y] 6 N = stns[Y] 7 } -
xxxxxxxxxx 1 if(stns[Y] > N){ 2 L = L ++ [Y] 3 N = stns[Y] 4 } 5 if(stns[Y] == N){ 6 L = [Y] 7 } -
xxxxxxxxxx 1 if(stns[Y] == N){ 2 L = L ++ [Y] 3 N = stns[Y] 4 } 5 else{ 6 L = [Y] 7 } -
xxxxxxxxxx 1 if(stns[Y] > N){ 2 L = L ++ [Y] 3 N = stns[Y] 4 exitloop 5 } 6 if(stns[Y] == N){ 7 L = [Y] 8 }
Question 5
The following pseudocode is executed using the āShopping Billsā dataset. At the end of the execution, countPairs should store the list of triples such that every triple has two items and the number of times both the items have been purchased together. For example if āMilkā and āBreadā have been purchased together three times, then the triple would be [āMilkā, āBreadā, 3].
The procedure getPair(X) returns the list of pairs of items purchased in card X. For example if āMilkā, āBreadā, and āSugarā are present in the card X, then getPair(X) will return [[āMilkā, āBreadā], [āMilkā, āSugarā], [āBreadā, āSugarā]].
Choose the correct code fragment to complete the pseudocode.
xxxxxxxxxx
1
countPairs = [], xpairs = [], pairList = []
2
while(Pile 1 has more cards){
3
Read the top card X from Pile 1
4
xpairs = getPairs(X)
5
pairList = pairList ++ xpairs
6
Move X from Pile 1 to Pile 2
7
}
8
ā
9
while(length(pairList) > 1){
10
restList = [], firstPair = [], tripple = []
11
pairCount = 0, item1 = "None", item2 = "None"
12
firstPair = first(pairList)
13
item1 = first(firstPair)
14
item2 = last(firstPair)
15
foreach pair in rest(pairList){
16
if(first(pair) == item1 or last(pair) == item1){
17
***************************
18
** FILL THE CODE **
19
***************************
20
}
21
else{
22
restList = restList ++ [pair]
23
}
24
25
}
26
tripple = [item1, item2, pairCount]
27
countPairs = countPairs ++ [tripple]
28
pairList = restList
29
}
-
xxxxxxxxxx 1 if(first(pair) == item2 or last(pair) == item2){ 2 pairCount = pairCount + 1 3 } 4 else{ 5 restList = restList ++ [pair] 6 } -
xxxxxxxxxx 1 if(first(pair) == item1 or first(pair) == item2){ 2 pairCount = pairCount + 1 3 } 4 else{ 5 restList = restList ++ [pair] 6 } -
xxxxxxxxxx 1 if(last(pair) == item2 and first(pair) == item2){ 2 pairCount = pairCount + 1 3 } 4 else{ 5 restList = restList ++ [pair] 6 } -
xxxxxxxxxx 1 if(first(pair) == item1 and last(pair) == item1){ 2 pairCount = pairCount + 1 3 } 4 else{ 5 restList = restList ++ [pair] 6 }
Question 6
The given pseudocode is executed using the āScoresā dataset. At the end of the execution of given pseudocode, choose the correct option(s)? It is a Multiple Select Question (MSQ).
xxxxxxxxxx
1
topper = findTop(Table 1)
2
Procedure findTop(Table 1)
3
max = 0, top = []
4
while(Table 1 has more rows){
5
Read the first row X from Table 1
6
if(X.Total > max){
7
max = X.Total
8
top = [X.SeqNo, max]
9
}
10
Move X to Table 2
11
}
12
Move all rows from Table 2 to Table 1
13
return(top)
14
End findTop
- topper is a list of two elements.
- first(topper) represents the sequence number of one of the students who have scored the highest total marks
- first(topper) is the list of the sequence numbers of the students who have scored the highest total marks
- last(topper) is the highest total mark from the Table 1
Question 7
Consider the procedure findTop mentioned in question 6. The following pseudocode is executed using the āScoresā dataset. Let removeRow(Table, z) deletes the row of Table with sequence number z. What will marksList represent at the end of the execution of given pseudocode?
xxxxxxxxxx
1
topper = [], marksList = []
2
while(Table 1 has more rows){
3
topper = findTop(Table 1)
4
removeRow(Table 1, first(topper))
5
marksList = marksList ++ [topper]
6
}
- List of sequence numbers in ascending order based on the total marks
- List of sequence numbers in descending order based on the total marks
- List of pairs of sequence number and total marks in descending order based on the total marks
- List of pairs of sequence number and total marks in ascending order based on the total marks
Question 8
Consider the marksList created in question 7. What will topList represent at the end of the execution of the given pseudocode?
xxxxxxxxxx
1
topList = [], counter = 1
2
max = last(first(marksList))
3
foreach pair in marksList{
4
if(last(pair) != max){
5
max = last(pair)
6
counter = counter + 1
7
}
8
if(counter < 4){
9
topList = topList ++ [first(pair)]
10
}
11
}
- List of sequence numbers of students whose total marks is in the top three total marks
- List of sequence numbers of three students whose total marks is in the top three total marks
- List of pairs of the sequence number and the total marks of students whose total marks is in the top four total marks
- List of pairs of the sequence number and the total marks of students whose total marks is in the top three total marks
Question 9
At the end of execution, the value of posSen will be
- 2
- 3
- 4
- 5
Question 10
At the end of execution, the value of neutSen will be
- 2
- 3
- 4
- 5
Question 11
At the end of execution, the value of commentType will be
- neutSen
- posSen
- negSen
Question 12
Which of the following statement(s) is/are True about medalDict based on the above pseudocode? It is a Multiple Select Question (MSQ).
- medalDict is a procedure which accepts the sequence number of a player and returns True if the player has won all the three types of medals otherwise returns False.
- medalDict is a dictionary with sequence numbers of players mapped to True if the player has won all the three types of medals otherwise mapped to False.
- medalDict is a nested dictionary with sequence numbers of players mapped to a dictionary with medals as keys mapped to True if the player has won that medal.
- medalDict is a dictionary with sequence numbers of players mapped to the list of distinct medals won by the player.
Question 13
Which of the following statement(s) is/are True about repeatDict based on the above pseudocode? It is a Multiple Select Question (MSQ).
- repeatDict is a procedure which accepts the sequence number of a player and returns True if the player has won at least one type of medal more than one time.
- repeatDict is a dictionary with sequence numbers of players mapped to the number of medals which the player has won more than one time.
- repeatDict is a dictionary with sequence numbers of players mapped to True if the player has won at least one type of medal more than one time.
- repeatDict is a dictionary with sequence numbers of players mapped to True if the player has won at least one type of medal more than one time otherwise mapped to False.
Question 14
Let G, S, and B be the lists of the sequence numbers of the players who have won Gold medal, Silver medal, and Bronze medal respectively. If n is the sequence number of a player, then choose the correct implementation of medalDict?
-
xxxxxxxxxx 1 Procedure medalDict(n) 2 count = 0 3 if(member(G, n)){ 4 count = count + 1 5 } 6 if(member(S, n)){ 7 count = count + 1 8 } 9 if(member(B, n)){ 10 count = count + 1 11 } 12 return(count) 13 End nSub -
xxxxxxxxxx 1 Procedure medalDict(n) 2 count = 0 3 if(member(G, n)){ 4 count = count + 1 5 } 6 if(member(S, n)){ 7 count = count + 1 8 } 9 if(member(B, n)){ 10 count = count + 1 11 } 12 if(count == 3){ 13 return(True) 14 } 15 return(False) 16 End nSub -
xxxxxxxxxx 1 medalDict = {} 2 while(Table 1 has more rows){ 3 Read the first row X from Table 1 4 count = 0 5 if(member(G, X.SeqNo)){ 6 count = count + 1 7 } 8 if(member(S, X.SeqNo)){ 9 count = count + 1 10 } 11 if(member(B, X.SeqNo)){ 12 count = count + 1 13 } 14 if(count == 3){ 15 medalDict[SeqNo] = True 16 } 17 Move X to Table 2 18 } -
xxxxxxxxxx 1 medalDict = {} 2 while(Table 1 has more rows){ 3 Read the first row X from Table 1 4 medalDict[SeqNo] = {} 5 if(member(G, X.SeqNo)){ 6 medalDict[SeqNo]["Gold"] = True 7 } 8 if(member(S, X.SeqNo)){ 9 medalDict[SeqNo]["Silver"] = True 10 } 11 if(member(Bronze, X.SeqNo)){ 12 medalDict[SeqNo]["Bronze"] = True 13 } 14 Move X to Table 2 15 }