CCHS Math Recursion Worksheets M Heinen CS-A 12/5/2013. Recursion Worksheets Plus Page 1 of 6

Similar documents
AP COMPUTER SCIENCE A

Exam 2. Programming I (CPCS 202) Instructor: M. G. Abbas Malik. Total Marks: 40 Obtained Marks:

Fall CS 101: Test 2 Name UVA ID. Grading. Page 1 / 4. Page3 / 20. Page 4 / 13. Page 5 / 10. Page 6 / 26. Page 7 / 17.

AP CS Unit 3: Control Structures Notes

CS 101 Spring 2007 Midterm 2 Name: ID:

Assignment-1 Final Code. Student.java

CS141 Programming Assignment #6

This exam is open book. Each question is worth 3 points.

CSC 231 DYNAMIC PROGRAMMING HOMEWORK Find the optimal order, and its optimal cost, for evaluating the products A 1 A 2 A 3 A 4

Midterm Examination (MTA)

Lab 6. Name: Checked:

1. What is the difference between a compiler and an interpreter? Also, discuss Java s method.

Introduction to Computer Science Unit 2. Notes

Beginning Programming (Java) Test 2/Version 1 CMSC 1513 Spring 2013

Week 14 Lab A Linked List of Integers Maximum Points = 10

CS 101 Exam 2 Spring Id Name

CIS 1068 Program Design and Abstraction Spring2016 Midterm Exam 1. Name SOLUTION

CS 231 Data Structures and Algorithms Fall Event Based Programming Lecture 06 - September 17, Prof. Zadia Codabux

ITERATION WEEK 4: EXMAPLES IN CLASS

AP Computer Science Unit 1. Programs

1 Short Answer (15 Points Each)

Page 1 / 3. Page 2 / 18. Page 3 / 8. Page 4 / 21. Page 5 / 15. Page 6 / 20. Page 7 / 15. Total / 100. Pledge:

AP Computer Science. TextLab05 Java Assignment. Assignment Purpose: Do not copy this file, which is provided. TextLab05 Student Version

CS212 Midterm. 1. Read the following code fragments and answer the questions.

private static final char[] Alphabet = "abcdefghijklmnopqrstuvwxyz".tochararray();

Loops. Eng. Mohammed Abdualal. Islamic University of Gaza. Faculty of Engineering. Computer Engineering Department

St. Edmund Preparatory High School Brooklyn, NY

Notes - Recursion. A geeky definition of recursion is as follows: Recursion see Recursion.

Tutorial 03. Exercise 1: CSC111 Computer Programming I

while (/* array size less than 1*/){ System.out.print("Number of students is invalid. Enter" + "number of students: "); /* read array size again */

It is a constructor and is called using the new statement, for example, MyStuff m = new MyStuff();

A token is a sequence of characters not including any whitespace.

Arrays. Eng. Mohammed Abdualal

Objectives of the lesson

Anatomy of a Java Program: Comments

C212 Early Evaluation Exam Mon Feb Name: Please provide brief (common sense) justifications with your answers below.

1. [3 pts] What is your section number, the period your discussion meets, and the name of your discussion leader?

Fundamentals of Programming Data Types & Methods

1 Short Answer (5 Points Each)

Name: Checked: Preparation: Response time experiment accessing the system clock

Unit 10: Sorting/Searching/Recursion

M105: Introduction to Programming with Java Midterm Examination (MTA) Makeup Spring 2013 / 2014

CP122 CS I. Chapter 13: Recursion

Section 003 Fall CS 170 Exam 1. Name (print): Instructions:

Chapter 3: Classes and Objects. CSC2010 Lab 9. Java Programming. Copyright 2000 W. W. Norton & Company. All rights reserved. FROM THE BEGINNING

Supplementary Test 1

More Things We Can Do With It! Overview. Circle Calculations. πr 2. π = More operators and expression types More statements

CS1083 Week 2: Arrays, ArrayList

CS110 Programming Language I. Lab 6: Multiple branching Mechanisms

Give one example where you might wish to use a three dimensional array

Introduction to Computer Science Unit 2. Notes

Introduction to Computer Science Unit 2. Exercises

University of Palestine. Mid Exam Total Grade: 100

Controls Structure for Repetition

Name: Checked: Preparation: Response time experiment accessing the system clock

CSC 1051 Algorithms and Data Structures I. Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University

CS141 Programming Assignment #5

Question 1 [20 points]

Handout 5 cs180 - Programming Fundamentals Spring 15 Page 1 of 8. Handout 5. Loops.

Darrell Bethea May 10, MTWRF 9:45-11:15 AM Sitterson 011

Control Structures: if and while A C S L E C T U R E 4

CS5000: Foundations of Programming. Mingon Kang, PhD Computer Science, Kennesaw State University

Branching. Chapter 5 11/14/16 & 11/15/16

Loops. CSE 114, Computer Science 1 Stony Brook University

What two elements are usually present for calculating a total of a series of numbers?

COSC 236 Section 101 Computer Science 1 -- Prof. Michael A. Soderstrand

(A) 99 (B) 100 (C) 101 (D) 100 initial integers plus any additional integers required during program execution

Warm-Up! Coding Bat Ap-1

CSC 1051 Villanova University. CSC 1051 Data Structures and Algorithms I. Course website:

Object Oriented Programming. Java-Lecture 1

Object Oriented Programming with JAVA

Question: Total Points: Score:

CSCI Problem Solving, Programming and Computers Spring, 2016 Assignment 2 {Inheritance, Interfaces, Arrays}

1 Short Answer (10 Points Each)

JAVA PROGRAMMING LAB. ABSTRACT In this Lab you will learn to write programs for executing statements repeatedly using a while, do while and for loop

CSC 1051 Data Structures and Algorithms I

AL GHURAIR UNIVERSITY College of Computing. Objectives: Examples: Text-printing program. CSC 209 JAVA I

Data Structures Lecture 1

2.2 - Making Decisions

1 Short Answer (10 Points Each)

CSC 1051 Algorithms and Data Structures I. Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University

Sequence structure. The computer executes java statements one after the other in the order in which they are written. Total = total +grade;

Bjarne Stroustrup. creator of C++

Warm up Exercise. What are the types and values of the following expressions: * (3 + 1) 3 / / 2.0 (int)1.0 / 2

Practice Midterm 1. Problem Points Score TOTAL 50

CS Computers & Programming I Review_01 Dr. H. Assadipour

CSE 8A Lecture 12. Reading for next class: : Sounds! Today s topics: Logical Operators:! && Start PSA 6: Chromakey!

CSC 1051 Data Structures and Algorithms I

2. What are the two main components to the CPU and what do each of them do? 3. What is the difference between a compiler and an interpreter?

(A) 99 ** (B) 100 (C) 101 (D) 100 initial integers plus any additional integers required during program execution

Classes. Classes as Code Libraries. Classes as Data Structures

User-built data types Mutable and immutable data

CS 152: Data Structures with Java Hello World with the IntelliJ IDE

PRIMITIVE VARIABLES. CS302 Introduction to Programming University of Wisconsin Madison Lecture 3. By Matthew Bernstein

AP CS A Exam Review Answer Section

CSE 1223: Introduction to Computer Programming in Java Chapter 7 File I/O

Java Coding 3. Over & over again!

Data dependent execution order data dependent control flow

Lesson 7 Part 2 Flags

CMPS 11 Introduction to Programming Midterm 1 Review Problems

Transcription:

CS-A // arraysol[][] = r; import java.util.scanner; public class RecursionApp { static int r; // return value static int[][] arraysol = new int[][7]; // create a solution array public static void main(string[] args) { Scanner sc = new Scanner(System.in); WS w = new WS(); System.out.println("\n**** WS # - All "); System.out.println("\nWS - "); w.fun(); System.out.println("\nWS - "); w.fun(); System.out.println("\nWS - "); r = w.fun(); arraysol[][] = r; System.out.println("\nWS - "); r = w.fun(, ); arraysol[][] = r; System.out.println("\nWS - "); r = w.fun(, ); arraysol[][] = r; WS w = new WS(); System.out.println("\n**** WS # - All "); System.out.println("\nWS - "); w.fun(); arraysol[][] = ; System.out.println("\nWS - "); w.fun(); arraysol[][] = ; System.out.println("\nWS - "); r = w.fun(8); System.out.println("\nWS - "); r = w.fun(7, ); arraysol[][] = ; System.out.println("\nWS - "); r = w.fun(, ); arraysol[][] = r; WS w = new WS(); System.out.println("\n**** WS # - All "); System.out.println("\nWS - "); r = w.fun(8); arraysol[][] = r; System.out.println("\nWS - "); r = w.fun(,8); arraysol[][] = r; System.out.println("\nWS - "); r = w.fun(8); arraysol[][] = r; System.out.println("\nWS - "); r = w.fun(); arraysol[][] = r; System.out.println("\nWS - "); r = w.fun(); arraysol[][] = r; WS w = new WS(); System.out.println("\n**** WS # - All "); System.out.println("\nWS - "); r = w.fun(); arraysol[][] = r; System.out.println("\nWS - "); Recursion Worksheets Plus Page of

CS-A // r = w.fun(); arraysol[][] = r; System.out.println("\nWS - "); r = w.go(); arraysol[][] = r; System.out.println("\nWS - "); r = w.go(); arraysol[][] = r; System.out.println("\nWS - "); r = w.fly(); arraysol[][] = r; // print out solution array System.out.println("\n\t*** Solution Array ***"); System.out.println("\nWS\t\t\t\t\t\t"); System.out.println(" " +"\t" +arraysol[][]+"\t" +arraysol[][]+"\t" +arraysol[][]+"\t" +arraysol[][]+"\t" +arraysol[][]+"\t" +arraysol[][]); System.out.println(" " + "\t" +arraysol[][]+"\t" +arraysol[][]+"\t" +arraysol[][]+"\t" +arraysol[][]+"\t" +arraysol[][]+"\t" +arraysol[][]); System.out.println(" " + "\t" +arraysol[][]+"\t" +arraysol[][]+"\t" +arraysol[][]+"\t" +arraysol[][]+"\t" +arraysol[][]+"\t" +arraysol[][]); System.out.println(" " + "\t" +arraysol[][]+"\t" +arraysol[][]+"\t" +arraysol[][]+"\t" +arraysol[][]+"\t" +arraysol[][]+"\t" +arraysol[][]); System.out.println("\nWS - "); r = w.fly(); arraysol[][] = r; sc.close(); Recursion Worksheets Plus Page of

CS-A // public class WS { public class WS { public void fun(int x) { if (x >= ) { fun(x - ); public void fun(int x) { if (x < ) { else { fun(x - ); public int fun(int x) { if (x < ) { else { return x + fun(x - ); public int fun(int x, int y) { if (y == ) { else { return fun(x, y - ) + x; public void fun(int x) { if (x >= ) { fun(x - ); public void fun(int x) { if (x < ) { else { fun(x - ); public int fun(int x) { if (x < ) { else { return x + fun(x - ); public int fun(int x, int y) { if (y == ) { return y; else { return fun(x, y - ) + x; Recursion Worksheets Plus Page of

CS-A // public class WS { public int fun(int x) { if (x < ) { else { return x + fun(x - ); public int fun(int x, int y) { if (x <= ) { return y; else { return fun(x -, y - ) + y; public int fun(int x) { if (x < ) { else { return x + fun(x - ); public int fun(int x) { if (x < ) { return ; else { return x + fun(x - ) + fun(x - ); public class WS { public int fun(int x) { if (x < ) { return ; else { return x + fun(x - ) + fun(x - ); public int go(int x) { if (x < ) { return ; else { return x + go(x - ) + go(x - ); public int fly(int x) { if (x < ) { return ; else { return x + fly(x - ) + fly(x - ); Recursion Worksheets Plus Page of

CS-A // **** WS # - All WS - WS - WS - Returned value = WS -,,,,, Returned value = WS -, Returned value = **** WS # - All WS - WS - WS - 8 Returned value = WS - 7, Returned value = 7 WS -,,,, Returned value = **** WS # - All WS - 8 - Returned value = WS -, 8, 7 Returned value = WS - 8 Returned value = WS - - - - Returned value = WS - - - - Recursion Worksheets Plus Page of

CS-A // - - Returned value = 9 **** WS # - All WS - - Returned value = WS - - - - - - - - - Returned value = 7 WS - - - - Returned value = WS - - - Returned value = 7 WS - - - - Returned value = WS - - - - - Returned value = *** Solution Array *** WS 9 7 7 Recursion Worksheets Plus Page of