Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
383 views
in Technique[技术] by (71.8m points)

What will be the value of B at the end of execution of the pseudocode on the given data?

#Pseudocode
D = {“Mathematics”: { }, “Physics”: { }, “Chemistry”: { }}, B = 0
while (Table 1 has more rows) {
Read the first row X in Table 1
D = updateDictByField(D, X, “Mathematics” )
D = updateDictByField(D, X, “Physics” )
D = updateDictByField(D, X, “Chemistry” )
Move X to Table 2
}
while (Table 2 has more rows) {
Read the first row X in Table 2
if (eligible(D, X) > 1) {
B=B+1
}
Move X to Table 1
}
Procedure updateDictByField(D, Y. Subject)
if (isKey(D[Subject], Y.CityTown)) {
if (D[Subject][Y.CityToun] < Y.Subject) {
D[Subject][Y.CityTown] = Y Subject
}
}
else {
D[Subject][Y.City Town] = Y Subject
}
return (D)
End updateDictByField

Procedure eligible(D, X) {
SubList = [Afathematics” , “Physics”, ~Chemistry"|, C = 0
foreach Subject in SubList {
if (D[Subject][X. CityTown] == X.Subject) {
C=C+1
}
}
return (C)
End eligible

#dataTable |CardNo|Name|Gender|DateOfBirth|CityTown|Mathematics|Physics|Chemistry|Total|0|Bhuvanesh|M|7 Nov|Erode|68|64|78|210|1|Harish|M|3 Jun|Salem|62|45|91|198|2|Shasnank|M|4 Jan|Chennai|57|54|77|188|3|Rida|F|5 May|Chennai|42|53|78|173|4|Ritka|F|17 Nov|Madurai|87|64|89|240|5|Akshaya|F|8 Feb|Chennai|71|92|84|247|6|Sameer|M|23 Mar|Ambur|81|82|87|250|7|Aditya|M|15 Mar|Vellore|84|92|76|252|8|Surya|M|28 Feb|Bengaluru|74|64|51|189|9|Clarence|M|6 Dec|Bengaluru|63|88|73|224|10|Kavya|F|12 Jan|Chennai|64|72|68|204|11|Rahul|M|30 Apr|Bengaluru|97|92|92|261|12|Srinidhi|F|14 Jan|Chennai|52|64|71|187|13|Gopi|M|6 May|Madurai|65|73|89|227|14|Sophia|F|25 Jul|Trichy|89|62|93|244|15|Goutami|F|22 Sep|Theni|78|58|90|224|16|Tauseef|M|30 Dec|Trichy|87|86|43|216|17|Arshad|M|14 Dec|Chennai|62|81|67|210|18|Abirami|F|9 Oct|Erode|72|92|97|261|19|Vetrivel|M|30 Aug|Trichi|56|78|62|196|20|Kalyan|M|17 Sep|Vellore|93|68|91|252|21|Monika|F|15 Mar|Bengaluru|78|69|74|221|22|Priya|F|17 Jul|Nagercoil|62|62|57|181|23|Deepika|F|13 May|Bengaluru|97|91|88|276|24|Siddharth|M|26 Dec|Madurai|44|72|58|174|25|Geeta|M|22 May|Chennai|87|75|92|254|26|JK|M|22 Jul|Chennai|74|71|82|227|27|Jagan|M|4 Mar|Madurai|81|76|52|209|28|Nisha|F|10 Sep |Madurai|74|83|83|240|29|Naveen|M|13 Oct|Vellore|72|66|81|219|

question from:https://stackoverflow.com/questions/65858368/what-will-be-the-value-of-b-at-the-end-of-execution-of-the-pseudocode-on-the-giv

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...