This problem can be easily solved using a stack. My explanation of Tracing recursive methods explains the technique.
Also see my complete 2009 AP CS A Multiple Choice solutions.
2009 AP CS A Multiple Choice #40 Solution (as PDF)
This is an embedded Microsoft Office presentation, powered by Office Web Apps.
Email (will not be published)(required)
Copyright © 2019 mrHorn.com, Inc.
Brandon Horn - President
AP is a trademark of The College Board which was not involved with the production of, and does not endorse, this site.