Some code I've scribbled down from the pseudo code in CH7 of "Computer Science Illuminated" by Dale and Lewis