4 ms·
Related: linked lists are way overused in chaining hash tables when dynamic arrays could be used instead. One reason sometimes given is that linked lists are am
by senderista 6y ago
Related: linked lists are way overused in chaining hash tables when dynamic arrays could be used instead. One reason sometimes given is that linked lists are amenable to the "move-to-front" heuristic (move just-accessed element to the head of the list), but one can do the same thing in dynamic arrays by swapping the just-accessed element with the first element (a better heuristic though is to fix some k and swap with the kth element if the accessed element is outside the top k, or swap with the preceding element if it's in the top k).