This preview shows pages 1–2. Sign up to view the full content.
Homework Assignment 5
A medley of recursive methods
Overview
This lab assignment will introduce you to thinking recursively. You will implement four short recursive
methods. You are allowed to use iterative structures (for loops, while loops, etc), but the purpose of this lab is
recursive thinking, and your solutions must exemplify this. You may work with a partner, if you choose to,
for this lab (see the note at the bottom of this page).
Objectives
•
Practice using recursive thinking to solve seemingly complex problems;
•
Practice writing and working with recursive methods;
•
Practice developing algorithms to solve specific problems;
•
Practice working in small teams to solve problems, design algorithms and write code
Phonewwords (Phone Words)
Take out your cell phone right now (or look at the picture below). Next to each number key (except for the 1
key), there are three or four letters.
Each digit can be thought of as one of its corresponding letters. Given a (10 digit) phone number, we want to
generate all possible words that this phone number can be interpreted as (we don't care if they aren't English
words). For example, the phone number "7466396737" can be read as "phonewords" (check this out for
yourself). Actually, we want to be able to generate all corresponding words for a phone number of any
length. So, "228" can be read as "cat" and "bat", as well as many other words.
Write the method
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
This is the end of the preview. Sign up
to
access the rest of the document.
 Spring '09
 ReidMiller

Click to edit the document details