function top_avg(students){
	var len = students.length;
	var top01 = 40;
	if(len > 10000){
		top01 = 80;
	}
	var sum = 0.0;
	for (var i = 0; i < top01; i++) {
		sum += students[i].marks;
	}
	return sum/top01;
}

The above code means, everyone rank will jump suddenly when the $10000^{th}$ user comes, while that’s fine, it can be improved. 

By calculating the $top01$ value dynamically based on the length of `students.length`, just multiply by $0.0001$

Unless its already done. I just checked the $github$.

 

 

posted in Others Feb 14, 2020
1,373 views
3
Like
0
Love
0
Haha
0
Wow
0
Angry
0
Sad

2 Comments

2 Comments

Like
Well, the github code is not the actual one we are using now. But still not following the dynamic model due to obvious reasons. Instead we have more set sizes and this will be adjusted based on per year trend.
Like
I see, buckets/sets should work too.