Q45.The following pseudocode is executed on the Words dataset. What will `Count1` represent at the end of execution?
```
D = {}
A = 0, Total = 0, Count = 0
while(Table 1 has more rows) {
Read the first row X in Table 1
Total = Total + X.LetterCount
Count = Count + 1
if(isKey(D, X.Word)) {
D[X.Word]["Freq"] = D[X.Word]["Freq"] + 1
}
else {
D[X.Word] = {}
D[X.Word]["Freq"] = 1
D[X.Word]["LC"] = X.LetterCount
}
if(D[X.Word]["Freq"] > A) {
A = D[X.Word]["Freq"]
}
Move row X to Table 2
}
Avg = Total / Count
Count1 = 0, Count2 = 0
foreach k in keys(D) {
if(D[k]["Freq"] == A) {
if(D[k]["LC"] > Avg) {
Count1 = Count1 + 1
}
else {
Count2 = Count2 + 1
}
}
}
```
Save
Check
Details
Q45
6 Aug 2023
Q45.The following pseudocode is executed on the Words dataset. What will `Count1` represent at the end of execution?
```
D = {}
A = 0, Total = 0, Count = 0
while(Table 1 has more rows) {
Read the first row X in Table 1
Total = Total + X.LetterCount
Count = Count + 1
if(isKey(D, X.Word)) {
D[X.Word]["Freq"] = D[X.Word]["Freq"] + 1
}
else {
D[X.Word] = {}
D[X.Word]["Freq"] = 1
D[X.Word]["LC"] = X.LetterCount
}
if(D[X.Word]["Freq"] > A) {
A = D[X.Word]["Freq"]
}
Move row X to Table 2
}
Avg = Total / Count
Count1 = 0, Count2 = 0
foreach k in keys(D) {
if(D[k]["Freq"] == A) {
if(D[k]["LC"] > Avg) {
Count1 = Count1 + 1
}
else {
Count2 = Count2 + 1
}
}
}
```