Transcription of Algorthms from Sedgewick and Wayne