Object Oriented Software Design (NTU, Class Even, Spring 2009) Final Examination Problem Sheet TIME: 06/16/2009, 14:20 17:20

Size: px
Start display at page:

Download "Object Oriented Software Design (NTU, Class Even, Spring 2009) Final Examination Problem Sheet TIME: 06/16/2009, 14:20 17:20"

Transcription

1 Final Examination Problem Sheet TIME: 06/16/2009, 14:20 17:20 This is a closed-book exam. Any form of cheating or lying will not be tolerated. Students can get zero scores and/or fail the class and/or be kicked out of school and/or receive other punishments for those kinds of misconducts. Both English and Traditional Chinese (if suited) are allowed for answering the questions. We do not accept any other languages. 1 POO Zoo The two unicorn friends (Pinky and Bluey) of Charlie the unicorn are persuading him to come to the POOZoo, the POOCasino, or the POOBoard, instead of the candy mountain. To add those popular characters to POO, one of the members in your programming team wrote the following code: 1 class Unicorn { 2 int x, y ; 3 static void walk ( Unicorn u ){ u. x += 2 ; } 5 class C h a r l i e { 6 private int count ; 7 S t r i n g r e j e c t ( S t r i n g p l a c e ) { return I don t want to go to + p l a c e ; } 8 S t r i n g agree ( S t r i n g p l a c e ){ return Okay, okay, I l l go to + p l a c e ; } 9 public void do unicorn walk ( ) { Unicorn. walk ( this ) ; } 10 public S t r i n g a c t i o n ( S t r i n g p l a c e ){ 11 do unicorn walk ( ) ; count++; 12 i f ( count < 2) return r e j e c t ( p l a c e ) ; 13 else { count = 0 ; return agree ( p l a c e ) ; } 1 15 } 16 class Pinky{ 17 public void do unicorn walk ( ) { Unicorn. walk ( this ) ; } 18 public S t r i n g a c t i o n ( S t r i n g p l a c e ){ 19 do unicorn walk ( ) ; 20 return Charlie, Charlie, l e t s go to + p l a c e ; 21 } 22 } 23 class Bluey { 24 public void do unicorn walk ( ) { Unicorn. walk ( this ) ; } 25 public S t r i n g a c t i o n ( S t r i n g p l a c e ){ 26 do unicorn walk ( ) ; 27 return Yes, Charlie, + p l a c e ; 28 } 29 } The other programmer in your team write the following code: 1 class Demo1{ 2 public static void main ( S t r i n g [ ] argv ){ 3 Unicorn [ ] uarr = new Unicorn [ 3 ] ; 4 uarr [ 2 ] = new C h a r l i e ( ) ; uarr [ 1 ] = new Bluey ( ) ; uarr [ 0 ] = new Pinky ( ) ; 5 for ( int t = 0 ; t < 2 ; t++) 6 for ( int i = 0 ; i < uarr. l ength ; i++) 7 System. out. p r i n t l n ( uarr [ i ]. a c t i o n ( the POO Zoo ) ) ; 8 } 9 } You want the two pieces of code, when coupled together, can show the correct output like Charlie, Charlie, let s go to the POO Zoo 1 of 5

2 Yes, Charlie, the POO Zoo I don t want to go to the POO Zoo Charlie, Charlie, let s go to the POO Zoo Yes, Charlie, the POO Zoo Okay, okay, I ll go to the POO Zoo However, the code above doesn t work, because it cannot pass the compiler (hahaha)! (1) (5%) Assume that you can ask another programmer to re-write the latter piece of code, while the former remains unchanged. Write down the correct and clean lines that you expect her/him to write to cope with the former piece. (2) (15%) Assume that you can ask another programmer to re-write the former piece of code, while the latter remains unchanged. Write down the correct and clean lines that you expect her/him to write to cope with the latter piece. Note that the shortness of your answers is a big concern, of course, because you are in a time-bounded exam. The quality of your answers would also be taken into account. 2 POO Calculus Yes, yes, yes. It is purely evil to remind you that your calculus exam is coming soon. But imagine that you can bring your well-designed POO Calculus code to the JVM of your cellphone to the calculus exam, wouldn t it be fantastic? Let s start developing this useful software for future students. One basic component in calculus is the real-valued function from R to R. We will define it as an abstract Java class to begin with. 1 abstract class Function { public abstract double e v a l ( double x ) ; } A (symbolically) differentiable function f(x) is a function such that f (x) has a closed form; a (symbolically) integrable function g(x) is a function such that g(x)dx has a closed form. The two properties would be represented by the following interfaces. 1 interface D i f f e r e n t i a b l e { Function d i f f ( ) ; } 2 interface I n t e g r a b l e { Function i n t e ( ) ; } Thus, a function h(x) = exp( 0.5 x 2 ) would probably be like 1 class SDExp extends Function implements D i f f e r e n t i a b l e { 2 public double e v a l ( double x ){ return Math. exp ( 0.5 x x ) ; } 3 public Function d i f f ( ) { return new Multiply (new Poly ( 1.0, 1 ), this ) ; } (1) (5%) We know that the exponential function g(x) = exp(x) is both differentiable and integrable, with g (x) = g(x) = g(x)dx. Complete the code below. 1 class Exp extends Function implements D i f f e r e n t i a b l e, I n t e g r a b l e { 2 // w r i t e your code 3 } (2) (5%) We know that the simple polynomial function g(x) = αx D is both differentiable and integrable, with g (x) = αdx D 1 and g(x)dx = α D+1 xd+1. Complete the code below. 1 class Poly extends Function implements D i f f e r e n t i a b l e, I n t e g r a b l e { 2 double deg ; 3 double c o e f ; 4 Poly ( double coef, double degree ){ this. c o e f = c o e f ; this. deg = deg ; } 5 // w r i t e your code 6 } 2 of 5

3 (3) (5%) The Sum class represents the sum of two functions. Use the fact that (f + g) = f + g and (f + g) = f + g to complete the code below. What would happen if either f or g is not symbolically differentiable? 1 class Sum extends Function implements D i f f e r e n t i a b l e, I n t e g r a b l e { 2 Function f, g ; 3 Sum( Function f, Function g ){ this. f = f ; this. g = g ; } 4 // w r i t e your code 5 } (4) (5%) Without simplifying any equations manually, write the code that computes the value of d ( 3x 2 + 2x ( exp(x)dx) ). dx x=2 Note: You can use Math.exp(double a), which returns exp(a).you can also use Math.pow(double a, double b), which returns a b. 3 POO Search POO is deciding to make many things searchable boards, articles, friend lists, messages, to name a few. Of course, one wouldn t expect to waste time on writing the same search program several times. Hence, Java Generics is the time-saver (?!). Your programming team decides to start by having a Searchable interface, where its match function determines whether the instance matches the query string. 1 interface Searchable { boolean match ( S t r i n g query ) ; } 2 class POOBoard implements Searchable { /... / } 3 class POOFriend implements Searchable { /... / } 4 class POOGoodFriend extends POOFriend{ /... / } Now, the team wants a Searcher class that works with anything Searchable. A naïve idea is 1 class Searcher extends ArrayList<Searchable >{ /... / } However, such a Searcher allows us to mix POOBoard and POOFriend altogether in the list, which does not look very right. What the team really wants is something like 1 class Searcher <E> extends ArrayList<E>{ /... / } But that doesn t look right, either, because we can then have something like 1 Searcher<Integer > s = new Searcher <Integer >(); 2 s. add (new I n t e g e r ( 3 ) ) ; Nevertheless, Integer does not implement Searchable and hence should not be allowed by Searcher. (1) (10%) Write down the declaration of Searcher that would allow it to work on only any Searchable type but not a mixture of them. Your declaration should look like 1 class Searcher<E > extends ArrayList<E > where the underlines should be replaced by your own code or removed. (2) (5%) The core method of Searcher is a method called search, which looks like 1 Searcher <E > search ( S t r i n g query ){ 2 Searcher<E > r e s u l t = new Searcher<E >(); 3 for ( int i =0; i<this. s i z e ( ) ; i ++){ 4 E o = this. get ( i ) ; 5 i f ( o. match ( query ) ) { r e s u l t. add ( o ) ; } 6 } 7 return r e s u l t ; 8 } 3 of 5

4 Fill in the necessary part in the underlines above that would allow the code below to work. 1 Searcher <POOBoard> s = new Searcher<POOBoard>(); 2 // add some POOBoards t o s 3 Searcher <POOBoard> r e s = s. search ( Gossip ) ; (3) (5%) Another method of Searcher is called addsearchresult, which looks like 1 Searcher< > addsearchresult ( Searcher< > orig, S t r i n g query ){ 2 this. addall ( o r i g. s earch ( query ) ) ; 3 return this ; Fill in the necessary part in the underlines above that would allow the code below to work. 1 Searcher <POOGoodFriend> sg = new Searcher<POOGoodFriend >(); 2 // add some POOGoodFriends t o s g 3 Searcher <POOFriend> s2 = new Searcher<POOFriend >(); 4 Searcher <POOFriend> r2 = s2. addsearchresult ( sg, CharlieL ) ; 4 POO Exception Consider the following two exceptions that are used in POO. 1 class NetworkDisconnectException extends IOException { } 2 class UserNotExistException extends Exception { } The following hierarchy in Java might also be helpful. 1 class Exception extends Throwable{ } 2 class IOException extends Exception { } 3 class RuntimeException extends Exception { } 4 class NullPointerException extends RuntimeException { } (1) (20%, with partial credit) A lazy programmer in your team wrote the following exception handling code, which, of course, is not of the top quality. Please use the correct try-catch-finally mechanism to make the code better-organized while doing exactly the same thing (if exception only happens during action 1, action 2, and action 3). 1 try{ 2 a c t i o n 1 ( ) ; 3 i f ( a c t i o n 2 ( ) ) { a c t i o n 3 ( ) ; } 4 else { a c t i o n 0 ( ) ; return ; } 5 } 6 catch ( Throwable e ){ 7 a c t i o n 4 ( ) ; 8 i f ( e instanceof NullPointerException ){ a c t i o n 5 ( ) ; } 9 i f ( e instanceof Exception ){ a c t i o n 6 ( ) ; } 10 i f ( e instanceof NetworkDisconnectException ){ a c t i o n 7 ( ) ; } 11 i f ( e instanceof UserNotExistException ){ a c t i o n 8 ( ) ; } 12 a c t i o n 0 ( ) ; 13 } Note that the shortness of your answers is a big concern, of course, because you are in a time-bounded exam. The quality of your answers would also be taken into account. 4 of 5

5 5 POO Love It is nearly the Lunar Valentine s Day, and POO BBS decides to have an activity of love sending. Basically, any user is allowed to send love messages to as well as to receive love messages from other users. To handle the process, every user is modeled as an instance of POOUser that contains an instance variable love count, which is increased by 1 whenever a love message is received. A POOLoveThread is associated with each user to handle the sending process. 1 class POOUser{ 2 private int l o v e c o u n t ; 3 public void i n c r e a s e l o v e c o u n t ( ) { int r = l o v e c o u n t + 1 ; l o v e c o u n t = r ; } 5 6 c l a s s POOLoveThread extends Thread{ 7 POOUser user ; 8 POOLoveThread (POOUser user ){ this. user = user ; } 9 void i n c r e a s e l o v e c o u n t (POOUser r e c e i v e r ){ 10 r e c e i v e r. i n c r e a s e l o v e c o u n t ( ) ; 11 } 12 public void run ( ) { 13 while ( true ){ 14 POOUser r e c e i v e r = f i n d u s e r ( a s k r e c e i v e r ( user ) ) ; 15 i n c r e a s e l o v e c o u n t ( r e c e i v e r ) ; 16 } 17 } 18 } In the stories below, user M is a freshman who is competing for the title of most-loved user and hence is very serious about his love counts. (1) (5%) When running the code above, M complains that he should have gotten three love messages from three different junior users J1, J2, J3. Nevertheless, M s love count only shows 1. Is it possible? If so, give an example of three concurrent calls to M.increase love count() that results in such a behavior. If not, state your arguments to M. (2) (5%) A programmer in your team tried to respond to M s complaint by adding the keyword synchronized to the declaration of the increase love count method in POOLoveThread. One day later, M comes back and has the same complaint again. Is it possible? Why or why not? (3) (5%) Another programmer in your team tried to respond to M s complaint by adding the keyword synchronized to the declaration of the increase love count method in POOUser. One day later, M comes back and has the same complaint again. Is it possible? Why or why not? (4) (5%) Assume that the code of POOUser cannot be changed. How would you change the code of POOLoveThread to resolve the complaint of M? 5 of 5

1 Java Night Countdown (30%)

1 Java Night Countdown (30%) Midterm Examination Problem Sheet TIME: 04/18/2009, 19:00 21:00 This is a open-textbook exam. You can use the Absolute Java textbook as your reference during the exam. Any other references are not allowed.

More information

Algebra Exam. Solutions and Grading Guide

Algebra Exam. Solutions and Grading Guide Algebra Exam Solutions and Grading Guide You should use this grading guide to carefully grade your own exam, trying to be as objective as possible about what score the TAs would give your responses. Full

More information

More About Methods. Hsuan-Tien Lin. Deptartment of CSIE, NTU. OOP Class, March 8-9, 2010

More About Methods. Hsuan-Tien Lin. Deptartment of CSIE, NTU. OOP Class, March 8-9, 2010 More About Methods Hsuan-Tien Lin Deptartment of CSIE, NTU OOP Class, March 8-9, 2010 H.-T. Lin (NTU CSIE) More About Methods OOP 03/08-09/2010 0 / 24 Methods: the Basic Method (1/2, Callee s View) 1 p

More information

An Invitation to Mathematics Prof. Sankaran Vishwanath Institute of Mathematical Sciences, Chennai. Unit I Polynomials Lecture 1A Introduction

An Invitation to Mathematics Prof. Sankaran Vishwanath Institute of Mathematical Sciences, Chennai. Unit I Polynomials Lecture 1A Introduction An Invitation to Mathematics Prof. Sankaran Vishwanath Institute of Mathematical Sciences, Chennai Unit I Polynomials Lecture 1A Introduction Hello and welcome to this course titled An Invitation to Mathematics.

More information

Introduction to Algebra: The First Week

Introduction to Algebra: The First Week Introduction to Algebra: The First Week Background: According to the thermostat on the wall, the temperature in the classroom right now is 72 degrees Fahrenheit. I want to write to my friend in Europe,

More information

Techniques of Java Programming

Techniques of Java Programming Legi-Nr.:... Techniques of Java Programming ETH Zurich Date: 9 May 008 Family name, first name:... Student number:... I confirm with my signature, that I was able to take this exam under regular circumstances

More information

Homework #1 RELEASE DATE: 09/26/2013 DUE DATE: 10/14/2013, BEFORE NOON QUESTIONS ABOUT HOMEWORK MATERIALS ARE WELCOMED ON THE FORUM.

Homework #1 RELEASE DATE: 09/26/2013 DUE DATE: 10/14/2013, BEFORE NOON QUESTIONS ABOUT HOMEWORK MATERIALS ARE WELCOMED ON THE FORUM. Homework #1 REEASE DATE: 09/6/013 DUE DATE: 10/14/013, BEFORE NOON QUESTIONS ABOUT HOMEWORK MATERIAS ARE WECOMED ON THE FORUM. Unless granted by the instructor in advance, you must turn in a printed/written

More information

Section 20: Arrow Diagrams on the Integers

Section 20: Arrow Diagrams on the Integers Section 0: Arrow Diagrams on the Integers Most of the material we have discussed so far concerns the idea and representations of functions. A function is a relationship between a set of inputs (the leave

More information

1.20 Formulas, Equations, Expressions and Identities

1.20 Formulas, Equations, Expressions and Identities 1.0 Formulas, Equations, Expressions and Identities Collecting terms is equivalent to noting that 4 + 4 + 4 + 4 + 4 + 4 can be written as 6 4; i.e., that multiplication is repeated addition. It s wise

More information

Basic Java OOP 10/12/2015. Department of Computer Science & Information Engineering. National Taiwan University

Basic Java OOP 10/12/2015. Department of Computer Science & Information Engineering. National Taiwan University Basic Java OOP 10/12/2015 Hsuan-Tien Lin ( 林軒田 ) htlin@csie.ntu.edu.tw Department of Computer Science & Information Engineering National Taiwan University ( 國立台灣大學資訊工程系 ) Hsuan-Tien Lin (NTU CSIE) Basic

More information

Section 3.1: Definition and Examples (Vector Spaces), Completed

Section 3.1: Definition and Examples (Vector Spaces), Completed Section 3.1: Definition and Examples (Vector Spaces), Completed 1. Examples Euclidean Vector Spaces: The set of n-length vectors that we denoted by R n is a vector space. For simplicity, let s consider

More information

Math 300: Final Exam Practice Solutions

Math 300: Final Exam Practice Solutions Math 300: Final Exam Practice Solutions 1 Let A be the set of all real numbers which are zeros of polynomials with integer coefficients: A := {α R there exists p(x) = a n x n + + a 1 x + a 0 with all a

More information

Series Handout A. 1. Determine which of the following sums are geometric. If the sum is geometric, express the sum in closed form.

Series Handout A. 1. Determine which of the following sums are geometric. If the sum is geometric, express the sum in closed form. Series Handout A. Determine which of the following sums are geometric. If the sum is geometric, exress the sum in closed form. 70 a) k= ( k ) b) 50 k= ( k )2 c) 60 k= ( k )k d) 60 k= (.0)k/3 2. Find the

More information

Math 20 Spring Discrete Probability. Midterm Exam

Math 20 Spring Discrete Probability. Midterm Exam Math 20 Spring 203 Discrete Probability Midterm Exam Thursday April 25, 5:00 7:00 PM Your name (please print): Instructions: This is a closed book, closed notes exam. Use of calculators is not permitted.

More information

Lecture Notes 17. Randomness: The verifier can toss coins and is allowed to err with some (small) probability if it is unlucky in its coin tosses.

Lecture Notes 17. Randomness: The verifier can toss coins and is allowed to err with some (small) probability if it is unlucky in its coin tosses. CS 221: Computational Complexity Prof. Salil Vadhan Lecture Notes 17 March 31, 2010 Scribe: Jonathan Ullman 1 Interactive Proofs ecall the definition of NP: L NP there exists a polynomial-time V and polynomial

More information

Homework #3 RELEASE DATE: 10/28/2013 DUE DATE: extended to 11/18/2013, BEFORE NOON QUESTIONS ABOUT HOMEWORK MATERIALS ARE WELCOMED ON THE FORUM.

Homework #3 RELEASE DATE: 10/28/2013 DUE DATE: extended to 11/18/2013, BEFORE NOON QUESTIONS ABOUT HOMEWORK MATERIALS ARE WELCOMED ON THE FORUM. Homework #3 RELEASE DATE: 10/28/2013 DUE DATE: extended to 11/18/2013, BEFORE NOON QUESTIONS ABOUT HOMEWORK MATERIALS ARE WELCOMED ON THE FORUM. Unless granted by the instructor in advance, you must turn

More information

Answers for Calculus Review (Extrema and Concavity)

Answers for Calculus Review (Extrema and Concavity) Answers for Calculus Review 4.1-4.4 (Extrema and Concavity) 1. A critical number is a value of the independent variable (a/k/a x) in the domain of the function at which the derivative is zero or undefined.

More information

Take the Anxiety Out of Word Problems

Take the Anxiety Out of Word Problems Take the Anxiety Out of Word Problems I find that students fear any problem that has words in it. This does not have to be the case. In this chapter, we will practice a strategy for approaching word problems

More information

Continuing discussion of CRC s, especially looking at two-bit errors

Continuing discussion of CRC s, especially looking at two-bit errors Continuing discussion of CRC s, especially looking at two-bit errors The definition of primitive binary polynomials Brute force checking for primitivity A theorem giving a better test for primitivity Fast

More information

CS Exam 1 Study Guide and Practice Exam

CS Exam 1 Study Guide and Practice Exam CS 150 - Exam 1 Study Guide and Practice Exam September 11, 2017 Summary 1 Disclaimer 2 Variables 2.1 Primitive Types.............................................. 2.2 Suggestions, Warnings, and Resources.................................

More information

CSE 311: Foundations of Computing I. Lecture 1: Propositional Logic

CSE 311: Foundations of Computing I. Lecture 1: Propositional Logic CSE 311: Foundations of Computing I Lecture 1: Propositional Logic About CSE 311 Some Perspective Computer Science and Engineering Programming CSE 14x Theory Hardware CSE 311 About the Course We will study

More information

CS 4110 Programming Languages & Logics. Lecture 25 Records and Subtyping

CS 4110 Programming Languages & Logics. Lecture 25 Records and Subtyping CS 4110 Programming Languages & Logics Lecture 25 Records and Subtyping 31 October 2016 Announcements 2 Homework 6 returned: x = 34 of 37, σ = 3.8 Preliminary Exam II in class on Wednesday, November 16

More information

Exam 3, Math Fall 2016 October 19, 2016

Exam 3, Math Fall 2016 October 19, 2016 Exam 3, Math 500- Fall 06 October 9, 06 This is a 50-minute exam. You may use your textbook, as well as a calculator, but your work must be completely yours. The exam is made of 5 questions in 5 pages,

More information

452 FINAL- VERSION E Do not open this exam until you are told. Read these instructions:

452 FINAL- VERSION E Do not open this exam until you are told. Read these instructions: 1 452 FINAL- VERSION E Do not open this exam until you are told. Read these instructions: 1. This is a closed book exam, though one sheet of notes is allowed. No calculators, or other aids are allowed.

More information

Introduction to Cryptography Lecture 13

Introduction to Cryptography Lecture 13 Introduction to Cryptography Lecture 13 Benny Pinkas June 5, 2011 Introduction to Cryptography, Benny Pinkas page 1 Electronic cash June 5, 2011 Introduction to Cryptography, Benny Pinkas page 2 Simple

More information

Chapter 26: Comparing Counts (Chi Square)

Chapter 26: Comparing Counts (Chi Square) Chapter 6: Comparing Counts (Chi Square) We ve seen that you can turn a qualitative variable into a quantitative one (by counting the number of successes and failures), but that s a compromise it forces

More information

Math 111, Introduction to the Calculus, Fall 2011 Midterm I Practice Exam 1 Solutions

Math 111, Introduction to the Calculus, Fall 2011 Midterm I Practice Exam 1 Solutions Math 111, Introduction to the Calculus, Fall 2011 Midterm I Practice Exam 1 Solutions For each question, there is a model solution (showing you the level of detail I expect on the exam) and then below

More information

Squaring and Unsquaring

Squaring and Unsquaring PROBLEM STRINGS LESSON 8.1 Squaring and Unsquaring At a Glance (6 6)* ( 6 6)* (1 1)* ( 1 1)* = 64 17 = 64 + 15 = 64 ( + 3) = 49 ( 7) = 5 ( + ) + 1= 8 *optional problems Objectives The goal of this string

More information

Math Lecture 3 Notes

Math Lecture 3 Notes Math 1010 - Lecture 3 Notes Dylan Zwick Fall 2009 1 Operations with Real Numbers In our last lecture we covered some basic operations with real numbers like addition, subtraction and multiplication. This

More information

6.896 Quantum Complexity Theory 30 October Lecture 17

6.896 Quantum Complexity Theory 30 October Lecture 17 6.896 Quantum Complexity Theory 30 October 2008 Lecturer: Scott Aaronson Lecture 17 Last time, on America s Most Wanted Complexity Classes: 1. QMA vs. QCMA; QMA(2). 2. IP: Class of languages L {0, 1} for

More information

MCS 260 Exam 2 13 November In order to get full credit, you need to show your work.

MCS 260 Exam 2 13 November In order to get full credit, you need to show your work. MCS 260 Exam 2 13 November 2015 Name: Do not start until instructed to do so. In order to get full credit, you need to show your work. You have 50 minutes to complete the exam. Good Luck! Problem 1 /15

More information

EQ: How do I convert between standard form and scientific notation?

EQ: How do I convert between standard form and scientific notation? EQ: How do I convert between standard form and scientific notation? HW: Practice Sheet Bellwork: Simplify each expression 1. (5x 3 ) 4 2. 5(x 3 ) 4 3. 5(x 3 ) 4 20x 8 Simplify and leave in standard form

More information

Math101, Sections 2 and 3, Spring 2008 Review Sheet for Exam #2:

Math101, Sections 2 and 3, Spring 2008 Review Sheet for Exam #2: Math101, Sections 2 and 3, Spring 2008 Review Sheet for Exam #2: 03 17 08 3 All about lines 3.1 The Rectangular Coordinate System Know how to plot points in the rectangular coordinate system. Know the

More information

Problem Decomposition: One Professor s Approach to Coding

Problem Decomposition: One Professor s Approach to Coding Problem Decomposition: One Professor s Approach to Coding zombie[1] zombie[3] Fewer Buuuuugs zombie[4] zombie[2] zombie[5] zombie[0] Fundamentals of Computer Science I Overview Problem Solving Understand

More information

Mathmatics 239 solutions to Homework for Chapter 2

Mathmatics 239 solutions to Homework for Chapter 2 Mathmatics 239 solutions to Homework for Chapter 2 Old version of 8.5 My compact disc player has space for 5 CDs; there are five trays numbered 1 through 5 into which I load the CDs. I own 100 CDs. a)

More information

1.4 Techniques of Integration

1.4 Techniques of Integration .4 Techniques of Integration Recall the following strategy for evaluating definite integrals, which arose from the Fundamental Theorem of Calculus (see Section.3). To calculate b a f(x) dx. Find a function

More information

CS1800: Sequences & Sums. Professor Kevin Gold

CS1800: Sequences & Sums. Professor Kevin Gold CS1800: Sequences & Sums Professor Kevin Gold Moving Toward Analysis of Algorithms Today s tools help in the analysis of algorithms. We ll cover tools for deciding what equation best fits a sequence of

More information

Notes on Complexity Theory Last updated: November, Lecture 10

Notes on Complexity Theory Last updated: November, Lecture 10 Notes on Complexity Theory Last updated: November, 2015 Lecture 10 Notes by Jonathan Katz, lightly edited by Dov Gordon. 1 Randomized Time Complexity 1.1 How Large is BPP? We know that P ZPP = RP corp

More information

FRESHMAN PRIZE EXAM 2017

FRESHMAN PRIZE EXAM 2017 FRESHMAN PRIZE EXAM 27 Full reasoning is expected. Please write your netid on your paper so we can let you know of your result. You have 9 minutes. Problem. In Extracurricula all of the high school students

More information

Review for Final Exam, MATH , Fall 2010

Review for Final Exam, MATH , Fall 2010 Review for Final Exam, MATH 170-002, Fall 2010 The test will be on Wednesday December 15 in ILC 404 (usual class room), 8:00 a.m - 10:00 a.m. Please bring a non-graphing calculator for the test. No other

More information

MATH UN Midterm 2 November 10, 2016 (75 minutes)

MATH UN Midterm 2 November 10, 2016 (75 minutes) Name: UNI: Instructor: Shrenik Shah MATH UN3025 - Midterm 2 November 10, 2016 (75 minutes) This examination booklet contains 6 problems. There are 10 sheets of paper including the front cover. This is

More information

2. Limits at Infinity

2. Limits at Infinity 2 Limits at Infinity To understand sequences and series fully, we will need to have a better understanding of its at infinity We begin with a few examples to motivate our discussion EXAMPLE 1 Find SOLUTION

More information

2.1 Definition. Let n be a positive integer. An n-dimensional vector is an ordered list of n real numbers.

2.1 Definition. Let n be a positive integer. An n-dimensional vector is an ordered list of n real numbers. 2 VECTORS, POINTS, and LINEAR ALGEBRA. At first glance, vectors seem to be very simple. It is easy enough to draw vector arrows, and the operations (vector addition, dot product, etc.) are also easy to

More information

WSMA Algebra - Expressions Lesson 14

WSMA Algebra - Expressions Lesson 14 Algebra Expressions Why study algebra? Because this topic provides the mathematical tools for any problem more complicated than just combining some given numbers together. Algebra lets you solve word problems

More information

Computer Science Introductory Course MSc - Introduction to Java

Computer Science Introductory Course MSc - Introduction to Java Computer Science Introductory Course MSc - Introduction to Java Lecture 1: Diving into java Pablo Oliveira ENST Outline 1 Introduction 2 Primitive types 3 Operators 4 5 Control Flow

More information

Class Note #20. In today s class, the following four concepts were introduced: decision

Class Note #20. In today s class, the following four concepts were introduced: decision Class Note #20 Date: 03/29/2006 [Overall Information] In today s class, the following four concepts were introduced: decision version of a problem, formal language, P and NP. We also discussed the relationship

More information

Announcements. CompSci 102 Discrete Math for Computer Science. Chap. 3.1 Algorithms. Specifying Algorithms

Announcements. CompSci 102 Discrete Math for Computer Science. Chap. 3.1 Algorithms. Specifying Algorithms CompSci 102 Discrete Math for Computer Science Announcements Read for next time Chap. 3.1-3.3 Homework 3 due Tuesday We ll finish Chapter 2 first today February 7, 2012 Prof. Rodger Chap. 3.1 Algorithms

More information

Remarks on Definitions

Remarks on Definitions Remarks on Definitions 1. Bad Definitions Definitions are the foundation of mathematics. Linear algebra bulges with definitions and one of the biggest challenge for students is to master them. It is difficult.

More information

This chapter covers asymptotic analysis of function growth and big-o notation.

This chapter covers asymptotic analysis of function growth and big-o notation. Chapter 14 Big-O This chapter covers asymptotic analysis of function growth and big-o notation. 14.1 Running times of programs An important aspect of designing a computer programs is figuring out how well

More information

Mathematical Induction

Mathematical Induction Mathematical Induction James K. Peterson Department of Biological Sciences and Department of Mathematical Sciences Clemson University January 12, 2017 Outline Introduction to the Class Mathematical Induction

More information

Some Review Problems for Exam 3: Solutions

Some Review Problems for Exam 3: Solutions Math 3355 Fall 018 Some Review Problems for Exam 3: Solutions I thought I d start by reviewing some counting formulas. Counting the Complement: Given a set U (the universe for the problem), if you want

More information

Derivatives: definition and first properties

Derivatives: definition and first properties September 5, 2017 Extra Office Hour Today, 11AM noon, 885 Evans. Lunch to follow if you want. DSP If you re a DSP student and need exam accommodations, please contact me if you haven t done that already.

More information

More on Methods and Encapsulation

More on Methods and Encapsulation More on Methods and Encapsulation Hsuan-Tien Lin Deptartment of CSIE, NTU OOP Class, March 31, 2009 H.-T. Lin (NTU CSIE) More on Methods and Encapsulation OOP(even) 03/31/2009 0 / 38 Local Variables Local

More information

Algebra. Here are a couple of warnings to my students who may be here to get a copy of what happened on a day that you missed.

Algebra. Here are a couple of warnings to my students who may be here to get a copy of what happened on a day that you missed. This document was written and copyrighted by Paul Dawkins. Use of this document and its online version is governed by the Terms and Conditions of Use located at. The online version of this document is

More information

Comprehensive Exam in Real Analysis Fall 2006 Thursday September 14, :00-11:30am INSTRUCTIONS

Comprehensive Exam in Real Analysis Fall 2006 Thursday September 14, :00-11:30am INSTRUCTIONS Exam Packet # Comprehensive Exam in Real Analysis Fall 2006 Thursday September 14, 2006 9:00-11:30am Name (please print): Student ID: INSTRUCTIONS (1) The examination is divided into three sections to

More information

Advanced topic: Space complexity

Advanced topic: Space complexity Advanced topic: Space complexity CSCI 3130 Formal Languages and Automata Theory Siu On CHAN Chinese University of Hong Kong Fall 2016 1/28 Review: time complexity We have looked at how long it takes to

More information

Great Theoretical Ideas in Computer Science

Great Theoretical Ideas in Computer Science 15-251 Great Theoretical Ideas in Computer Science Polynomials, Lagrange, and Error-correction Lecture 23 (November 10, 2009) P(X) = X 3 X 2 + + X 1 + Definition: Recall: Fields A field F is a set together

More information

Mathematics 3130 Show H is a subspace of V What it looks like in my head

Mathematics 3130 Show H is a subspace of V What it looks like in my head Mathematics 3130 Show H is a subspace of V What it looks like in my head Last revised: November 8, 2013 This document is intended to serve as a sort of diagram of my thought process when I am showing something

More information

Math 308 Midterm Answers and Comments July 18, Part A. Short answer questions

Math 308 Midterm Answers and Comments July 18, Part A. Short answer questions Math 308 Midterm Answers and Comments July 18, 2011 Part A. Short answer questions (1) Compute the determinant of the matrix a 3 3 1 1 2. 1 a 3 The determinant is 2a 2 12. Comments: Everyone seemed to

More information

Looking Ahead to Chapter 10

Looking Ahead to Chapter 10 Looking Ahead to Chapter Focus In Chapter, you will learn about polynomials, including how to add, subtract, multiply, and divide polynomials. You will also learn about polynomial and rational functions.

More information

Properties of Arithmetic

Properties of Arithmetic Excerpt from "Prealgebra" 205 AoPS Inc. 4 6 7 4 5 8 22 23 5 7 0 Arithmetic is being able to count up to twenty without taking o your shoes. Mickey Mouse CHAPTER Properties of Arithmetic. Why Start with

More information

CSE 311 Lecture 28: Undecidability of the Halting Problem. Emina Torlak and Kevin Zatloukal

CSE 311 Lecture 28: Undecidability of the Halting Problem. Emina Torlak and Kevin Zatloukal CSE 311 Lecture 28: Undecidability of the Halting Problem Emina Torlak and Kevin Zatloukal 1 Topics Final exam Logistics, format, and topics. Countability and uncomputability A quick recap of Lecture 27.

More information

CPSC 467: Cryptography and Computer Security

CPSC 467: Cryptography and Computer Security CPSC 467: Cryptography and Computer Security Michael J. Fischer Lecture 18 November 3, 2014 CPSC 467, Lecture 18 1/43 Zero Knowledge Interactive Proofs (ZKIP) Secret cave protocol ZKIP for graph isomorphism

More information

Thomas Jefferson Invitational Open in Informatics

Thomas Jefferson Invitational Open in Informatics Thomas Jefferson Invitational Open in Informatics Sample Problems (With Solutions) Version 2.01.1 By programmers, For programmers Preface Preface Welcome to the TJ IOI Sample Problems document. Here, you

More information

We can see that f(2) is undefined. (Plugging x = 2 into the function results in a 0 in the denominator)

We can see that f(2) is undefined. (Plugging x = 2 into the function results in a 0 in the denominator) In order to be successful in AP Calculus, you are expected to KNOW everything that came before. All topics from Algebra I, II, Geometry and of course Precalculus are expected to be mastered before you

More information

Special Theory Of Relativity Prof. Shiva Prasad Department of Physics Indian Institute of Technology, Bombay

Special Theory Of Relativity Prof. Shiva Prasad Department of Physics Indian Institute of Technology, Bombay Special Theory Of Relativity Prof. Shiva Prasad Department of Physics Indian Institute of Technology, Bombay Lecture - 6 Length Contraction and Time Dilation (Refer Slide Time: 00:29) In our last lecture,

More information

MATH 243E Test #3 Solutions

MATH 243E Test #3 Solutions MATH 4E Test # Solutions () Find a recurrence relation for the number of bit strings of length n that contain a pair of consecutive 0s. You do not need to solve this recurrence relation. (Hint: Consider

More information

1 Trees. Listing 1: Node with two child reference. public class ptwochildnode { protected Object data ; protected ptwochildnode l e f t, r i g h t ;

1 Trees. Listing 1: Node with two child reference. public class ptwochildnode { protected Object data ; protected ptwochildnode l e f t, r i g h t ; 1 Trees The next major set of data structures belongs to what s called Trees. They are called that, because if you try to visualize the structure, it kind of looks like a tree (root, branches, and leafs).

More information

An introduction to basic information theory. Hampus Wessman

An introduction to basic information theory. Hampus Wessman An introduction to basic information theory Hampus Wessman Abstract We give a short and simple introduction to basic information theory, by stripping away all the non-essentials. Theoretical bounds on

More information

The PROMYS Math Circle Problem of the Week #3 February 3, 2017

The PROMYS Math Circle Problem of the Week #3 February 3, 2017 The PROMYS Math Circle Problem of the Week #3 February 3, 2017 You can use rods of positive integer lengths to build trains that all have a common length. For instance, a train of length 12 is a row of

More information

Simple Math: Cryptography

Simple Math: Cryptography 1 Introduction Simple Math: Cryptography This section develops some mathematics before getting to the application. The mathematics that I use involves simple facts from number theory. Number theory is

More information

An Intuitive Introduction to Motivic Homotopy Theory Vladimir Voevodsky

An Intuitive Introduction to Motivic Homotopy Theory Vladimir Voevodsky What follows is Vladimir Voevodsky s snapshot of his Fields Medal work on motivic homotopy, plus a little philosophy and from my point of view the main fun of doing mathematics Voevodsky (2002). Voevodsky

More information

Lecture for Week 2 (Secs. 1.3 and ) Functions and Limits

Lecture for Week 2 (Secs. 1.3 and ) Functions and Limits Lecture for Week 2 (Secs. 1.3 and 2.2 2.3) Functions and Limits 1 First let s review what a function is. (See Sec. 1 of Review and Preview.) The best way to think of a function is as an imaginary machine,

More information

Lecture 6: Finite Fields

Lecture 6: Finite Fields CCS Discrete Math I Professor: Padraic Bartlett Lecture 6: Finite Fields Week 6 UCSB 2014 It ain t what they call you, it s what you answer to. W. C. Fields 1 Fields In the next two weeks, we re going

More information

Carefully tear this page off the rest of your exam. UNIVERSITY OF TORONTO SCARBOROUGH MATA37H3 : Calculus for Mathematical Sciences II

Carefully tear this page off the rest of your exam. UNIVERSITY OF TORONTO SCARBOROUGH MATA37H3 : Calculus for Mathematical Sciences II Carefully tear this page off the rest of your exam. UNIVERSITY OF TORONTO SCARBOROUGH MATA37H3 : Calculus for Mathematical Sciences II REFERENCE SHEET The (natural logarithm and exponential functions (

More information

Math Fundamentals for Statistics I (Math 52) Unit 7: Connections (Graphs, Equations and Inequalities)

Math Fundamentals for Statistics I (Math 52) Unit 7: Connections (Graphs, Equations and Inequalities) Math Fundamentals for Statistics I (Math 52) Unit 7: Connections (Graphs, Equations and Inequalities) By Scott Fallstrom and Brent Pickett The How and Whys Guys This work is licensed under a Creative Commons

More information

Multiple Choice Answers. MA 110 Precalculus Spring 2016 Exam 1 9 February Question

Multiple Choice Answers. MA 110 Precalculus Spring 2016 Exam 1 9 February Question MA 110 Precalculus Spring 2016 Exam 1 9 February 2016 Name: Section: Last 4 digits of student ID #: This exam has eleven multiple choice questions (five points each) and five free response questions (nine

More information

from Euclid to Einstein

from Euclid to Einstein WorkBook 2. Space from Euclid to Einstein Roy McWeeny Professore Emerito di Chimica Teorica, Università di Pisa, Pisa (Italy) A Pari New Learning Publication Book 2 in the Series WorkBooks in Science (Last

More information

Sequences and Series

Sequences and Series Sequences and Series What do you think of when you read the title of our next unit? In case your answers are leading us off track, let's review the following IB problems. 1 November 2013 HL 2 3 November

More information

Lecture 4: Constructing the Integers, Rationals and Reals

Lecture 4: Constructing the Integers, Rationals and Reals Math/CS 20: Intro. to Math Professor: Padraic Bartlett Lecture 4: Constructing the Integers, Rationals and Reals Week 5 UCSB 204 The Integers Normally, using the natural numbers, you can easily define

More information

Single-Predicate Derivations

Single-Predicate Derivations Single-Predicate Derivations Let s do some derivations. Start with an easy one: Practice #1: Fb, Gb Ⱶ (ꓱx)(Fx Gx) Imagine that I have a frog named Bob. The above inference might go like this: Bob is friendly.

More information

Calculus: What is a Limit? (understanding epislon-delta proofs)

Calculus: What is a Limit? (understanding epislon-delta proofs) Calculus: What is a Limit? (understanding epislon-delta proofs) Here is the definition of a limit: Suppose f is a function. We say that Lim aa ff() = LL if for every εε > 0 there is a δδ > 0 so that if

More information

Fall 2015 Exam 3 PIN: 17

Fall 2015 Exam 3 PIN: 17 MARK BOX problem points 0 10 1 10 2-6 50 7 15 8a/8b 15 NAME: PIN: 17 KEY-e-poo % 100 INSTRUCTIONS On Problem 0, fill in the blanks and boxes. As you know, if you do not make at least half of the points

More information

Ask. Don t Tell. Annotated Examples

Ask. Don t Tell. Annotated Examples Ask. Don t Tell. Annotated Examples Alfonso Gracia-Saz (alfonso@math.toronto.edu) The three principles: 1. Where is the student? 2. Help minimally. 3. Ask. Don t Tell. Ask. Don t Tell. 1 BRETT 1 Brett

More information

Exam 2 Solutions. x 1 x. x 4 The generating function for the problem is the fourth power of this, (1 x). 4

Exam 2 Solutions. x 1 x. x 4 The generating function for the problem is the fourth power of this, (1 x). 4 Math 5366 Fall 015 Exam Solutions 1. (0 points) Find the appropriate generating function (in closed form) for each of the following problems. Do not find the coefficient of x n. (a) In how many ways can

More information

You separate binary numbers into columns in a similar fashion. 2 5 = 32

You separate binary numbers into columns in a similar fashion. 2 5 = 32 RSA Encryption 2 At the end of Part I of this article, we stated that RSA encryption works because it s impractical to factor n, which determines P 1 and P 2, which determines our private key, d, which

More information

Lecture 6: Introducing Complexity

Lecture 6: Introducing Complexity COMP26120: Algorithms and Imperative Programming Lecture 6: Introducing Complexity Ian Pratt-Hartmann Room KB2.38: email: ipratt@cs.man.ac.uk 2015 16 You need this book: Make sure you use the up-to-date

More information

Generating Function Notes , Fall 2005, Prof. Peter Shor

Generating Function Notes , Fall 2005, Prof. Peter Shor Counting Change Generating Function Notes 80, Fall 00, Prof Peter Shor In this lecture, I m going to talk about generating functions We ve already seen an example of generating functions Recall when we

More information

ACTIVITY 3. Learning Targets: 38 Unit 1 Equations and Inequalities. Solving Inequalities. continued. My Notes

ACTIVITY 3. Learning Targets: 38 Unit 1 Equations and Inequalities. Solving Inequalities. continued. My Notes Learning Targets: Write inequalities to represent real-world situations. Solve multi-step inequalities. SUGGESTED LEARNING STRATEGIES: Create Representations, Guess and Check, Look for a Pattern, Think-Pair-Share,

More information

Modern Functional Programming and Actors With Scala and Akka

Modern Functional Programming and Actors With Scala and Akka Modern Functional Programming and Actors With Scala and Akka Aaron Kosmatin Computer Science Department San Jose State University San Jose, CA 95192 707-508-9143 akosmatin@gmail.com Abstract For many years,

More information

Methods of Mathematics

Methods of Mathematics Methods of Mathematics Kenneth A. Ribet UC Berkeley Math 10B April 19, 2016 There is a new version of the online textbook file Matrix_Algebra.pdf. The next breakfast will be two days from today, April

More information

Final Exam Version A December 16, 2014 Name: NetID: Section: # Total Score

Final Exam Version A December 16, 2014 Name: NetID: Section: # Total Score CS 374 : Algorithms and Models of Computation, Fall 2014 Final Exam Version A December 16, 2014 Name: NetID: Section: 1 2 3 # 1 2 3 4 5 6 Total Score Max 20 10 10 10 10 10 70 Grader Don t panic! Please

More information

ALGEBRAIC STRUCTURE AND DEGREE REDUCTION

ALGEBRAIC STRUCTURE AND DEGREE REDUCTION ALGEBRAIC STRUCTURE AND DEGREE REDUCTION Let S F n. We define deg(s) to be the minimal degree of a non-zero polynomial that vanishes on S. We have seen that for a finite set S, deg(s) n S 1/n. In fact,

More information

MS 2001: Test 1 B Solutions

MS 2001: Test 1 B Solutions MS 2001: Test 1 B Solutions Name: Student Number: Answer all questions. Marks may be lost if necessary work is not clearly shown. Remarks by me in italics and would not be required in a test - J.P. Question

More information

Instructor Notes for Chapters 3 & 4

Instructor Notes for Chapters 3 & 4 Algebra for Calculus Fall 0 Section 3. Complex Numbers Goal for students: Instructor Notes for Chapters 3 & 4 perform computations involving complex numbers You might want to review the quadratic formula

More information

MA554 Assessment 1 Cosets and Lagrange s theorem

MA554 Assessment 1 Cosets and Lagrange s theorem MA554 Assessment 1 Cosets and Lagrange s theorem These are notes on cosets and Lagrange s theorem; they go over some material from the lectures again, and they have some new material it is all examinable,

More information

Lecture 20: conp and Friends, Oracles in Complexity Theory

Lecture 20: conp and Friends, Oracles in Complexity Theory 6.045 Lecture 20: conp and Friends, Oracles in Complexity Theory 1 Definition: conp = { L L NP } What does a conp computation look like? In NP algorithms, we can use a guess instruction in pseudocode:

More information

Please bring the task to your first physics lesson and hand it to the teacher.

Please bring the task to your first physics lesson and hand it to the teacher. Pre-enrolment task for 2014 entry Physics Why do I need to complete a pre-enrolment task? This bridging pack serves a number of purposes. It gives you practice in some of the important skills you will

More information

M155 Exam 2 Concept Review

M155 Exam 2 Concept Review M155 Exam 2 Concept Review Mark Blumstein DERIVATIVES Product Rule Used to take the derivative of a product of two functions u and v. u v + uv Quotient Rule Used to take a derivative of the quotient of

More information

Pendulum Activity! Frequency, Length, and Gravity. Materials

Pendulum Activity! Frequency, Length, and Gravity. Materials Pendulum Activity! Frequency, Length, and Gravity A Pendulum is a weight (bob) that swings back and forth. Frequency is how many times something happens in a certain amount of time like how many times

More information