| ▲ | kazinator 7 hours ago | |||||||
> The main benefit of the Eytzinger layout is that all values needed for the first steps of the binary search are close together, so they can be cached efficiently: we put the root at index 1 and the two children of the node at index i are at 2i and 2i + 1. This is exactly what is done in good old binary heaps; though binary heaps do not maintain a balanced binary tree, only the property that key(parent) < key(left_child) and key(parent) < key(right_child). Binary heaps don't support efficient search for a particular key. I don't remember ever reading a description of binary heaps which mentioned Eytzinger. This is because the layout for binary heaps was discovered without knowledge of Eytzinger. It may have been Knuth who discovered Eytzinger and made the connection? It's quite obvious that this layout is good for caching. The first few layers of the tree will all fit into a single VM page, the nodes closest to the root into one cache line. Then the subsequent layers are similarly packed in order. Let's say that k layers of the tree fit into page. If the search path from root to leaf is 3k, it should touch only three pages, right? | ||||||||
| ▲ | jackhalford 2 hours ago | parent [-] | |||||||
Is « cacheability » a property of the data structure or of the lookup algorithm? | ||||||||
| ||||||||