Quoted from RTR:One question - Perhaps one you software devs in the crowd can explain how the algorithm thinks pencils are related to eggs?
It's more than likely based on correlation with the current orders going on. If a lot of people are buying eggs and pencils (like to homeschool their kids), then when you add eggs to your cart it thinks "hey, maybe this guy wants pencils too!".