Hello, I am learning bucket sorting. I don't understand the logic of a piece of code very well; or it is about the principle of calculating the number of elements in the bucket sorting bucket. code show as below:
....
const buketCount: number =
Math.floor((maxValue - minxValue) / bucketsSize) + 1; // --> Why is it necessary to add 1 when calculating the number of elements in the bucket? I do not really understand.
const bukets: number[][] = [];
for (let i: number = 0; i < buketCount; i++) {
bukets[i] = [];
}
....
If you see, I hope to help me explain, thank you very much