Download presentation

Presentation is loading. Please wait.

Published byNathanael Cross Modified over 2 years ago

1
CS 112 - Fall 2012, Lab 01 Haohan Zhu

2
Boston University Slideshow Title Goes Here CS 112 - Fall 2012, Lab 01 2 4/17/2015 Using Piazza http://www.piazza.com/bu/fall2012/cs112a1 http://www.piazza.com/bu/fall2012/cs112a1 Any question related to the course

3
Boston University Slideshow Title Goes Here CS 112 - Fall 2012, Lab 01 3 4/17/2015 Using WebSubmit http://cs-websubmit.bu.edu/main.py?courseid=cs112 http://cs-websubmit.bu.edu/main.py?courseid=cs112 Submit all assignments via WebSubmit

4
Boston University Slideshow Title Goes Here CS 112 - Fall 2012, Lab 01 4 4/17/2015 Lab Sections and Office Hours Attendence Office Hours: Tuesday. 5-6:30 p.m. Wednesday. 3-4:30 p.m. Tutoring Hour: http://www.bu.edu/cs/resources/tutoring/ http://www.bu.edu/cs/resources/tutoring/

5
Boston University Slideshow Title Goes Here CS 112 - Fall 2012, Lab 01 5 4/17/2015 Stack and Function Stack: Last In First Out (LIFO) Function F1 F2 F1 F2 F3 Call F1 F2 F3 Return F1 F2 F1 Return

6
Boston University Slideshow Title Goes Here CS 112 - Fall 2012, Lab 01 6 4/17/2015 Recursive Function F1 Call F1 Return F1 Return Base Case Same function, Different variables

7
Boston University Slideshow Title Goes Here CS 112 - Fall 2012, Lab 01 7 4/17/2015 Recursive Function Base Case (what to do with trivial inputs) Terminating Conditions Most logical errors occur at ‘Base Case’ Not only one base case, maybe many cases Recursive Call (how to solve the problem) Most difficult part to design a recursive function Understand which variables are changing, and which are constant.

8
Boston University Slideshow Title Goes Here CS 112 - Fall 2012, Lab 01 8 4/17/2015 Practice Implementing Exponentiation Write a function to recursively compute the function f(x,n) = x^n Compare your results with the built ‐ in java function Math.pow(x, n) n is a non-negative integer

9
Boston University Slideshow Title Goes Here CS 112 - Fall 2012, Lab 01 9 4/17/2015 Practice Consider f(x,n) = x^(n/2) * x^(n/2) What do you need to do if n is odd? Count number of recursive calls Count time by using: System.nanoTime()

Similar presentations

OK

MCS 177 Lab Fall 2014 Sept. 2, 2014. GUSTAVUS ADOLPHUS COLLEGEgustavus.edu Contact Info Course Instructor: Louis Yu Lab.

MCS 177 Lab Fall 2014 Sept. 2, 2014. GUSTAVUS ADOLPHUS COLLEGEgustavus.edu Contact Info Course Instructor: Louis Yu Lab.

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Ppt on care of public property record Ppt on central limit theorem applet Ppt on total internal reflection occurs Ppt on drought in india Pptm to ppt online converter Ppt on wireless sensor networks applications Ppt on ufo and aliens found Ppt on store design Slideshare ppt on cloud computing Ppt on young uncle comes to town