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 :-
Implement algorithms for inserting, deleting and searching nodes in a single linked list.

Solution :-
Insert : To insert a new node in the beginning of the list, make the next pointer of the new node point to the head of the list and make the new node as head . For inserting at the end, just traverse through the entire list and move to the last node, then make the next pointer of the last node point to the new node.
Suppose, you want to insert a new node p between two nodes x and y ( current list is x -> y ) . Then, make next of p point to y and next of x point to p . Resulting list is x -> p -> y .
Delete : Suppose the current list is x -> y -> z. To delete x , just make the head point to y and delete x . To delete z , just make the next of y point to NULL and delete z. To delete y , make the next of x point to z and delete y ( resulting list is x -> z ).
Search : To search a node, the list has to be traversed starting from the head of the list.