Greetings

# Greetings - 15-121: Introduction to Data Structures...

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

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.

Unformatted text preview: 15-121: Introduction to Data Structures Exercise 09/10/2009 Relevant Reading: • Section 9.1 of the online text. Topic: Recursion. • Chapter 7 in the Lewis and Chase book. Greetings Fall 2009 Due: Thu, Sept 10 end of lab Assignment: (worth 2 exercise points) the code or run it. You may work in pairs on this exercise. You may NOT type in Consider the code at the bottom of this page. 1) What is the output of this code? 2) Change the line that reads f2(1); to f2(2);? What is the output now? 3) Change the same line to f2(3);? What is the output now? Handin: Choose 1 of: • Turn in your written answers If you worked in a pair, be sure both names are on your paper. • Put your answers in a file "Greetings.txt", create a zip file with it and submit it via the online handin system. If you worked in a pair, be sure both names are on the top of the file. /* This is just a silly demo program. */ public class Demo { public static void main(String args) { System.out.println("Greetings"); f2(1); System.out.println( "Farewell"); } //************* public static void f1(int i) { if (i == 0) { System.out.println( "HOWDY !"); } else { System.out.println( "Bon jour"); f2(i - 1); System.out.println( "au revoir"); } } //************* public static void f2(int i) { System.out.println( "hola" ); f1 (i); System.out.println( "adios "); } } ...
View Full Document

## This document was uploaded on 12/19/2009.

### Page1 / 2

Greetings - 15-121: Introduction to Data Structures...

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

View Full Document
Ask a homework question - tutors are online