Week 6 - Graded Assignment 6 - (Sep 2025 - CT - Qualifier)
The due date for submitting this assignment has passed. Due on 2025-11-05, 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-11-05, 20:44 IST
Note: to view the Data used
Question 1
In the “Scores” table, let S be the list of sequence numbers of rows which have marks greater than 75 in at least one subject. What does the variable count represent at the end of the execution of the pseudocode given below?
xxxxxxxxxx
1
count = 0
2
while(Table 1 has more rows){
3
Read the first row X in Table 1
4
foreach c in S{
5
if (X.SeqNo == c){
6
if(X.Mathematics < 75 and X.Physics < 75){
7
count = count + 1
8
}
9
}
10
}
11
Move X to Table 2
12
}
- Number of students who have scored less than 75 in both Mathematics and Physics
- Number of students who have scored more than 75 in Chemistry
- Number of students who have scored less than 75 in both Mathematics and Physics, but more than 75 in Chemistry
- Number of students who have scored less than 75 in all three subjects
Status: Yes, the answer is correct. Score: 3
Accepted Answers:
- Number of students who have scored less than 75 in both Mathematics and Physics, but more than 75 in Chemistry
Question 2
The following pseudocode is executed using the “Words” dataset. Assume that the rows in Table 1 are sorted in the increasing order of sequence number. What does the list L contain at the end of execution?
xxxxxxxxxx
1
L = []
2
A = "None"
3
Read the first row X in Table 1
4
A = X.PartOfSpeech
5
Move X to Table 2
6
while(Table 1 has more rows){
7
Read the first row X in Table 1
8
if(X.PartOfSpeech == "Noun"){
9
if(A == "Adjective"){
10
L = L ++ [X.Word]
11
}
12
}
13
A = X.PartOfSpeech
14
Move X to Table 2
15
}
- The list of nouns that come immediately after an adjective
- The list of adjectives that come immediately after a noun
- The list of nouns that come immediately before an adjective
- The list of adjectives that come immediately before a noun
Status: Yes, the answer is correct. Score: 3
Accepted Answers:
- The list of nouns that come immediately after an adjective
Question 3
We have a non-empty list called authList that stores the names of all authors in the “Library” table sorted in alphabetical order of author names. There is one element corresponding to each book in the table. This results in many duplicates. The following procedure attempts to extract the unique list of authors, while preserving the sorted order. The pseudocode may have mistakes. Identify all such mistakes (if any). It is a Multiple Select Question (MSQ).
xxxxxxxxxx
1
uniqueList = [], prev = "None"
2
uniqueList = uniqueList ++ first(authList)
3
prev = first(authList)
4
foreach x in rest(authList){
5
if(x == prev){
6
uniqueList = uniqueList ++ [x]
7
}
8
prev = x
9
}
- Error in line 1
- Error in line 2
- Error in line 3
- Error in line 5
- Error in line 8
- No error
Accepted Answers:
- Error in line 2
- Error in line 5
Question 4
The procedure visitedShop returns the list of names of people who have visited a particular shop in the “Shopping Bills” dataset. It accepts the shop’s name as a parameter. Additionally, each customer must be represented exactly once in the returned list. The following pseudocode may have mistakes. Identify all such mistakes(if any). It is a Multiple Select Question (MSQ).
xxxxxxxxxx
1
Procedure visitedShop(shop)
2
S = "None"
3
while(Pile 1 has more cards){
4
Read the top card X from Pile 1
5
if(X.ShopName == shop){
6
if(not(member(S, X.CustomerName))){
7
S = S ++ [X.ShopName]
8
}
9
}
10
Move X to Pile 2
11
}
12
return(S)
13
End visitedShop
14
15
Procedure member(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 member
- Error in line 2
- Error in line 6
- Error in line 7
- Error in line 16
- Error in line 18
- Error in line 19
- No error
Status: Yes, the answer is correct. Score: 4
Accepted Answers:
- Error in line 2
- Error in line 7
- Error in line 16
Question 5
There may be multiple pairs having the same minimum distance. If we wish to find a pair of stations closest to the first station in the list, which of the following is the correct code fragment?
-
xxxxxxxxxx 1 if(diff < min){ 2 min = diff 3 pair = [first(prev), first(x)] 4 } -
xxxxxxxxxx 1 if(diff <= min){ 2 min = diff 3 pair = [first(prev), first(x)] 4 } -
xxxxxxxxxx 1 if(diff < min){ 2 min = diff 3 pair = [last(prev), last(x)] 4 } -
xxxxxxxxxx 1 if(diff <= min){ 2 min = diff 3 pair = [last(prev), last(x)] 4 }
Status: Yes, the answer is correct. Score: 4
Accepted Answers:
if(diff < min){ min = diff pair = [first(prev), first(x)] }
Question 6
There may be multiple pairs having the same minimum 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?
-
xxxxxxxxxx 1 if(diff < min){ 2 min = diff 3 pair = [first(prev), first(x)] 4 } -
xxxxxxxxxx 1 if(diff <= min){ 2 min = diff 3 pair = [first(prev), first(x)] 4 } -
xxxxxxxxxx 1 if(diff < min){ 2 min = diff 3 pair = [last(prev), last(x)] 4 } -
xxxxxxxxxx 1 if(diff <= min){ 2 min = diff 3 pair = [last(prev), last(x)] 4 }
Status: Yes, the answer is correct. Score: 4
Accepted Answers:
if(diff <= min){ min = diff pair = [first(prev), first(x)] }
Question 7
stns is a list that contains information about the sequence of stations visited by a train. Specifically, each element in this list is itself a list: [Arrival, Departure]. The first element in stns corresponds to the starting station for the train and the last element corresponds to the ending station for the train.
waitTime(arr, dep) is a procedure that accepts the arrival time and departure time of a train at a given station as input and returns the waiting time at that station in minutes.
We wish to find the average waiting time across all intermediate stations where the train stops and store this result in variable avg. The pseudocode may have mistakes. Identify all such mistakes (if any). It is a Multiple Select Question (MSQ).
xxxxxxxxxx
1
total = 0, count = 0, avg = 0
2
foreach x in init(rest(stns)){
3
total = total + waitTime(first(x), last(x))
4
count = count + 1
5
}
6
if(count != 0){
7
avg = total / count
8
}
- Error in line 2
- Error in line 3
- Error in line 4
- Error in line 6
- Error in line 7
- No error
Status: Yes, the answer is correct. Score: 4
Accepted Answers:
- No error
Question 8
Which of the following statements about the variable flag1 is True at the end of execution of the above pseudocode?
- It is True if and only if stn is a starting or ending station for at least one train in the list
- It is False if and only if stn is a starting or ending station for at least one train in the list
- It is True if and only if stn is a starting station for one train and ending station for some other train in the list
- It is False if and only if stn is a starting station for one train and ending station for some other train in the list
Status: Yes, the answer is correct. Score: 3
Accepted Answers:
- It is True if and only if stn is a starting or ending station for at least one train in the list
Question 9
What does the variable count represent at the end of execution of the above pseudocode?
- It is number of trains associated with stn
- It is the number of trains for which stn is a starting station
- It is the number of trains for which stn is an ending station
- It is the number of trains for which stn is neither a starting nor an ending station
Status: Yes, the answer is correct. Score: 3
Accepted Answers:
- It is the number of trains for which stn is neither a starting nor an ending station
Question 10
At the end of execution of the code given above, what can be said about the values stored by the Boolean variables flag1 and flag2?
- flag1 and flag2 always store the same value
- flag1 and flag2 always store opposite values
- flag1 always stores the value True
- flag2 always stores the value True
- There is no relationship between these two variables
Accepted Answers:
- flag1 and flag2 always store the same value