Introduction to Computer Science

Quiz 6 Study Guide

This page contains a list of things you should know before taking Quiz 6. If you have any questions as to the correct answers to any of these questions, please let me know.

Recursion

Lab 09 dealt with recursive functions: those functions which call themselves. You should understand how recursive functions work and be prepared to write simple recursive functions without the aid of the computer. You should know how the stack works with recursive functions; in particular, you should understand that each recursive call generates an additional stack frame and that multiple stack frames for the same function can exist simultaneously.

Exercises

Write each of the following functions both iteratively and recursively. Remember: your recursive function should not include any for or while loops.

Draw a stack diagram of summate(3) when it reaches its base case.

Classes and Objects

The most recent lectures (and Lab 10) have dealt with classes and objects. You should know how to write a class, how to create an object, and how to call an object’s methods. You should understand the purpose of classes and objects and be prepared to write and debug simple classes without the aid of the computer.

Exercises

Answer the following questions:

Write the following classes: