ch13Sections1-5

# ch13Sections1-5 - 13.10 Exercises, Problems, and Projects...

This preview shows pages 1–2. Sign up to view the full content.

13.10 Exercises, Problems, and Projects 13.10.1 Multiple Choice Exercises 1. may or may not be static 2. can be either of the above 3. base cases and general case 4. calls itself 5. false 6. a run-time error 7. a run-time error 8. a run-time error 13.10.2 Reading and Understanding Code 9. 0 10. 0 11. foo1 always returns 0 12. 7 13. 3 14. 5 15. foo2 returns argument % 10 16. There is no output 17. iH 18. olleH 19. foo3 outputs the argument String in reverse 20. 1 21. 5 22. 64 23. foo4 returns n to the power p 13.10.3 Fill in the Code 24. if ( s.charAt( 0 ) == c ) return ( 1 + foo( s.substring( 1, s.length( ) ), c ) ); else return foo( s.substring( 1, s.length( ) ), c ); 25. return foo( s.substring( 2, s.length( ) ) ); 26. return ( n + foo( n - 1 ) ); 27. if ( s.length( ) <= 1 ) return false; return true; else return foo( s.substring( 1, s.length( ) ) ); 28. if ( n >= 1000 ) // base case return n;

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
else // general case return foo( n * n );
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 10/05/2011 for the course CS 38 taught by Professor Stevehouseman during the Summer '09 term at Irvine Valley College.

### Page1 / 2

ch13Sections1-5 - 13.10 Exercises, Problems, and Projects...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online