Computational Thinking week 8 graded assignment Complete Solutions Are Discussed In This Blog. We Hope This Might Help You All In Matching Answers . Or For Some Others Reasons If Not Able To Complete Graded Assignments
-
The following pseudocode is executed using the “Scores” dataset. What will the values of A and B represent at the end of the execution?
1
D = {}
2
while(Table 1 has more rows){
3
Read the fist row X in Table 1
4
if(isKey(D, X.Town/City)){
5
if(D[X.Town/City] > X.Mathematics){
6
D[X.Town/City] = X.Mathematics
7
}
8
}
9
else{
10
D[X.Town/City] = X.Mathematics
11
}
12
Move X to Table 2
13
}
14
15
A = 0, B = 100
16
foreach Y in keys(D){
17
if(B == D[Y]){
18
A = A + 1
19
}
20
if(B > D[Y]){
21
A = 1
22
B = D[Y]
23
}
24
}
A = Cities where students score the highest marks in Mathematics
B = The highest marks in Mathematics
A = Number of cities where students score the highest marks in Mathematics
B = The highest marks in Mathematics
A = Number of cities where students score the lowest marks in Mathematics
B = The lowest marks in Mathematics
A = Always more than one
B = The highest marks in Mathematics
No, the answer is incorrect.
Score: 0
Accepted Answers:
A = Number of cities where students score the lowest marks in Mathematics
B = The lowest marks in Mathematics
2.The following pseudocode is executed using the “Scores” dataset. What will the value of B represent at the end of execution?
1
D = {}, B = 0
2
while(Table 1 has more rows){
3
Read the first row X in Table 1
4
D = updateDictByField(D, X.Physics)
5
Move X to Table 2
6
}
7
B = findAKey(D
8
9
Procedure updateDictByField(D, Value)
10
if(isKey(D, Value)){
11
D[Value] = D[Value] + 1
12
}
13
else{
14
D[Value] = 1
15
}
16
return(D)
17
End updateDictByField
18
19
Procedure findAKey(D)
20
Key = -1, Value = 0
21
foreach A in keys(D){
22
if(D[A] > Value){
23
Value = D[A]
24
Key = A
25
}
26
}
27
return(Key)
28
End findAKey
Number of repeated marks in Physics
Minimum marks in Physics
Maximum marks in Physics
Most frequent marks in Physics
No, the answer is incorrect.
Score: 0
Accepted Answers:
Most frequent marks in Physics
3.The following pseudocode is executed using the “Scores” dataset. What will be the value of B at the end of the execution?
1
D = {"Mathematics": {}, "Physics": {}, "Chemistry": {}}, B = 0
2
while(Table 1 has more rows){
3
Read the first row X in Table 1
4
D = updateDictByField(D, X, "Mathematics")
5
D = updateDictByField(D, X, "Physics")
6
D = updateDictByField(D, X, "Chemistry")
7
Move X to Table 2
8
}
9
10
while(Table 2 has more rows){
11
Read the first row X in Table 2
12
if(eligible(D, X) > 1){
13
B = B + 1
14
}
15
Move X to Table 1
16
}
17
18
Procedure updateDictByField(D, Y, Subject)
19
if(isKey(D[Subject], Y.Town/City)){
20
if(D[Subject][Y.Town/City] < Y.Subject){
21
D[Subject][Y.Town/City] = Y.Subject
22
}
23
}
24
else{
25
D[Subject][Y.Town/City] = Y.Subject
26
}
27
return(D)
28
End updateDictByField
29
30
Procedure eligible(D, X)
31
SubList = ["Mathematics", "Physics", "Chemistry"], C = 0
32
foreach Subject in SubList{
33
if(D[Subject][X.Town/City] == X.Subject){
34
C = C + 1
35
}
36
}
37
return(C)
38
End eligible
No, the answer is incorrect.
Score: 0
Accepted Answers:
4.The following pseudocode is executed using the “Shopping Bills” dataset. At the end of the execution, the variable D captures the following information: for each customer Z, D[Z] [“Shop”] stores the shops visited by Z, and D[Z] [“Category”] stores the categories of the items purchased by Z. But the pseudocode may have mistakes. Identify all such mistakes (if any). It is a Multiple Select Question (MSQ).
1
D = {}
2
while(Pile 1 has more cards){
3
Read the top card X in Pile 1
4
D = updateDictionary(D, X)
5
Move X to Pile 2
6
}
7
8
Procedure updateDictionary(D, Y)
9
if(not isKey(D, Y.CustomerName)){
10
D[Y.CustomerName] = {"Shop": [], "Category": []}
11
}
12
D[Y.CustomerName]["Shop"][Y.ShopName] = True
13
foreach A in Y.ItemList{
14
D[Y.CustomerName]["Shop"][A.Category] = True
15
}
16
return(D)
17
End updateDictionary
Error in Line 1
Error in Line 10
Error in Line 13
Error in Line 14
Error in Line 16
No error
No, the answer is incorrect.
Score: 0
Accepted Answers:
Error in Line 10
Error in Line 14
The following pseudocode is executed using the “station wise” cards of the “Train” dataset. At the end of the execution, STN captures the following information: for a station X, and a day of a week A, STN[X] [A] stores the number of trains running through X on the day A. [Note: Assume that for each station, the train list is given in a single card.]
1
STN = {}
2
while(Pile 1 has more cards){
3
Read the top card X in Pile 1
4
STN[X.StationName] = getInfo(STN, X)
5
Move X to Pile 2
6
}
Procedure getInfo(STN, X) *** * Fill the code * *** return(D) End getInfo
Choose the correct code fragment to complete the pseudocode.
D = {}
foreach A in X.TrainList{
foreach B in A.Days{
D[B] = 1
}
}
D = {"M": 0, "Tu": 0, "W": 0, "Th": 0, "F": 0, "Sa": 0, "Su": 0}
foreach A in X.TrainList{
foreach B in A.Days{
D[B] = 1
}
}
D = {}
foreach A in X.TrainList{
foreach B in A.Days{
D[B] = D[B] + 1
}
}
D = {"M": 0, "Tu": 0, "W": 0, "Th": 0, "F": 0, "Sa": 0, "Su": 0}
foreach A in X.TrainList{
foreach B in A.Days{
D[B] = D[B] + 1
}
}
No, the answer is incorrect.
Score: 0
Accepted Answers:
D = {"M": 0, "Tu": 0, "W": 0, "Th": 0, "F": 0, "Sa": 0, "Su": 0} foreach A in X.TrainList{ foreach B in A.Days{ D[B] = D[B] + 1 } }
The following pseudocode is executed using the “station wise” cards of the “Train” dataset. Consider the dictionary STN computed in the previous question. Choose the correct statement(s) from the options based on the pseudocode. It is a Multiple Select Question (MSQ).
1
Z = {}, D = {}
2
foreach A in keys(STN){
3
C = 0, Y = 0
4
D = STN[A]
5
foreach B in keys(D){
6
if(Y == D[B]){
7
C = C + 1
8
}
9
if(Y < D[B]){
10
C = 1
11
Y = D[B]
12
}
13
}
14
if(not isKey(Z, C)){
15
Z[C] = 0
16
}
17
Z[C] = Z[C] + 1
18
}
19
Keys of the dictionary Z is integer
There can be a value C such that Z[C] is zero
All values of the dictionary Z are non-zero
The number of keys in Z is 8
No, the answer is incorrect.
Score: 0
Accepted Answers:
Keys of the dictionary Z is integer
All values of the dictionary Z are non-zero
Consider the dictionary STN computed in the previous question. Choose the correct pseudocode to compute the number of stations which have trains passing through all days of a week.
Z = 0
foreach A in keys(STN){
foreach B in keys(STN[A]){
if(STN[A][B] < 1){
C = False
}
}
if(C){
Z = Z + 1
}
}
Z = 0
foreach A in keys(STN){
C = True
foreach B in keys(STN[A]){
if(STN[A][B] < 1){
C = False
}
}
if(C){
Z = Z + 1
}
}
Z = 0
foreach A in keys(STN){
C = True
foreach B in keys(STN[A]){
if(STN[A][B] < 1){
C = False
}
else{
C = True
}
}
if(C){
Z = Z + 1
}
}
Z = 0
foreach A in keys(STN){
C = False
foreach B in keys(STN[A]){
if(STN[A][B] < 1){
C = True
}
}
if(C){
Z = Z + 1
}
}
No, the answer is incorrect.
Score: 0
Accepted Answers:
Z = 0 foreach A in keys(STN){ C = True foreach B in keys(STN[A]){ if(STN[A][B] < 1){ C = False } } if(C){ Z = Z + 1 } }
The following pseudocode is executed using the “Words” table.
1
D = {}
2
while(Table 1 has more rows){
3
Read the first row X in Table 1
4
D = updateDictionary(D, X)
5
Move X to Table 2
6
}
7
Procedure updateDictionary(D, Y)
8
i = 1
9
while (i <= Y.LetterCount){
10
B = ith letter in Y.Word
11
if(isKey(D, B)){
12
D[B] = D[B] + 1
13
}
14
else{
15
D[B] = 1
16
}
17
i = i + 1
18
}
19
return(D)
20
End updateDictionary
What will D represent at the end of the execution?
Frequency count of each alphabet in the table
Frequency count of each word in the table
Most frequent alphabet in the table
Frequency count of each alphabet in each part of speech
No, the answer is incorrect.
Score: 0
Accepted Answers:
Frequency count of each alphabet in the table
Consider the dictionary D and the procedure updateDictionary() in the previous question. Let POS be a list that contains all part of speeches. Assume that given a dictionary D, there exists a procedure max such that max(D) returns a list of keys which are mapped to the maximum value. Choose the correct statement(s) from the options based on the following pseudocode. It is a Multiple Select Question (MSQ).
C = {"Overall": max(D)}
foreach A in POS{
Move all rows to Table 1
B = {}
while (Table 1 has more rows){
Read the first row X in Table 1
if(X.PartOfSpeech == A){
B = updateDictionary(B, X)
}
Move X to Table 2
}
C[A] = max(B)
}
length(keys(C)) is same as the number of different part of speeches in the input dataset
C captures the list of most frequent alphabet occurred overall in the dataset as well as for each part of speech
C captures the most frequent alphabet occurred overall in the dataset as well as for each part of speech
length(keys(C)) is one more than the number of different part of speeches in the dataset
No, the answer is incorrect.
Score: 0
Accepted Answers:
C captures the list of most frequent alphabet occurred overall in the dataset as well as for each part of speech
length(keys(C)) is one more than the number of different part of speeches in the dataset
The following pseudocode is executed using the “Shopping bills” dataset. What will D represent at the end of the execution?
1
D = {}
2
while(Pile 1 has more cards){
3
Read the top card X in Pile 1
4
D = updateDictionary(D, X)
5
Move X to Pile 2
6
}
7
8
Procedure updateDictionary(D, Y)
9
foreach A in Y.ItemList{
10
C = A.ItemName
11
if(isKey(D, C)){
12
if(isKey(D[C], Y.ShopName)){
13
if(D[C][Y.ShopName]["Price"] != A.Price){
14
D[C][Y.ShopName]["Flag"] = True
15
}
16
}
17
else{
18
D[C][Y.ShopName] = {"Price": A.Price, "Flag" : False}
19
}
20
}
21
else{
22
D[C] = {}
23
D[C][Y.ShopName] = {"Price": A.Price, "Flag" : False}
24
}
25
}
26
return (D)
27
End updateDictionary
For an item C, and a shop S, D[C] [S] [“Flag”] is set to True if and only if the item is sold for a constant price
For an item C, and a shop S, D[C] [S] [“Flag”] is set to True if and only if the item is billed in more than one bill
For an item C, and a shop S, D[C] [S] [“Flag”] is set to True if and only if the item is sold for variable price
For an item C, and a shop S, D[C] [S] [“Flag”] is set to True if and only if the item is billed exactly one bill
No, the answer is incorrect.
Score: 0
Accepted Answers:
For an item C, and a shop S, D[C] [S] [“Flag”] is set to True if and only if the item is sold for variable price