A few small edits for readability. I have also temporarily created a
new appendix called complexity.tex. I wanted to have the whole
algorithm on one page. Maybe we remove it later.