The best programs are written so that computing machines can perform them quickly and so that human beings can understand them clearly. A programmer is ideally an essayist who works with traditional aesthetic and literary forms as well as mathematical concepts, to communicate the way that an algorithm works and to convince a reader that the results will be correct. ― Donald E. Knuth

Algorithms

Linked List

Problem :-
Detect a loop in a given linked list.
Due to some bug, a node may contain a link to some previous node in the linked list. This creates an loop which would lead to a program hang while traversing the list.
Give an algorithmic approach to detect a loop if it exits.

Solution :-
This is a standard interview question with a very simple solution.
Maintain two pointers, slow pointer which iterates over each node in the list & fast pointer which takes two steps at a time i.e skips every alternate node. If at any point of time slow & fast pointers intersect, then there is a loop in the list.