Pseudo code for algorithm