Price your future right. 60% off with code BLACKSCHOLES at USD checkout. Offer ends in 1d 16h 01m 41s1 days 16 hours 1 minutes 41 seconds.
Price your future right. 60% off with code BLACKSCHOLES at USD checkout. Offer ends in 1d 16h 01m 41s1 days 16 hours 1 minutes 41 seconds.

Sign in to watch this lesson
Algorithms - Linear Data Structures · 4:41
A linked list gives every value its own node, so once you hold a node you can insert, erase or splice next to it in O(1). We reverse 1 to 5 in place with prev, cur and next, then measure the price on this Mac: summing a million ints from a scattered std::list is more than a thousand times slower than from a vector, which is why fast code keeps lists in index arrays. Finally a hash map from keys to list nodes turns the list into an LRU cache with O(1) get and put.