Tip: If you feel the need to memorise these algorithms in order to get a job, then perhaps you'll struggle if they hired you.
Actually, no. Though problems like these do (occasionally) occur IRL, the conditions under which you're expected to solve these problems in interviews ("on the spot, while I stare and grin at you, and occasionally interrupt you - and your result better be near-perfect, or GTFO!") --
have basically no relation to real-life development work.
By asking rote questions like this you're much more likely to decrease your chances of getting people who are good team builders as the lack of a focus on team cohesion will turn a lot of people off.