You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// TODO: Should be move bins that are full to a new vector to avoid having to iterate them?
}
And this could be improved to n.log(n) (complexity could be improved but for small sizes this probably isn't better) by storing the current size of each bin in a BTreeSet<(usize, usize)> where tuple is (size_of_the_bin, index_of_the_bin).
Using the BTreeSet::range function enables you to look up the best fit in O(log(n)) in the map.
The text was updated successfully, but these errors were encountered:
Ten0
changed the title
Seems n²
Seems n² but could be n.log(n)
Apr 17, 2024
Unless I'm mistaken the implementation of first fit is n² because it checks every bin for every item,
pack_it_up/src/online/first_fit.rs
Lines 27 to 39 in 3b74472
And this could be improved to n.log(n) (complexity could be improved but for small sizes this probably isn't better) by storing the current size of each bin in a
BTreeSet<(usize, usize)>
where tuple is (size_of_the_bin, index_of_the_bin).Using the
BTreeSet::range
function enables you to look up the best fit in O(log(n)) in the map.The text was updated successfully, but these errors were encountered: