CS Exam 1 Study Guide and Practice Exam
|
|
- Curtis Hutchinson
- 6 years ago
- Views:
Transcription
1 CS Exam 1 Study Guide and Practice Exam September 11, 2017 Summary 1 Disclaimer 2 Variables 2.1 Primitive Types Suggestions, Warnings, and Resources FAQs Printing 3.1 FAQs Conditional Statements 4.1 if-else if-else Statements Difference between if-if-if and if-else if-else Switch Statements Suggestions, Warnings, and Resources Scanners 5.1 Suggestions, Warnings, and Resources FAQs Practice Written Exam 6.1 Short Answer Tracing Code Programming Quiz Practice Exam 8 Suggestions for Studying and Test Taking 8.1 Written Programming Quiz Common Errors Challenges Answers to Practice Written and Programming Problems 9.1 Written Short Answer Tracing Programming
2 1 Disclaimer This is a review of the material so far, but there may be material on the exam not covered in this study guide. 2 Variables 2.1 Primitive Types The eight primitive types are: int, double, char, float, long, short, byte, and boolean. So far you ve learned about two reference types, a String and a Scanner. These are NOT a primitive types, you will learn why later in the semester. Below are a few examples of declaring a variable. Format: type var name;. 1 i n t i ; 2 double d ; 3 char c ; 4 S t r i n g s ; Below are a few examples of assigning a variable. Format: var name = value;. 1 i = 3 ; 2 d = 4. 5 ; 3 c = a ; 4 s = Hey a l l! ; Below are a few examples of initializing a variable. Initializing is the combination of declaring and assigning. Format: type var name = value; 1 boolean b = t r u e ; 2 f l o a t f = F ; 3 long l = 32L ; 4 S t r i n g r e s p o n s e = Yes ; Remember: Every variable must always have a declaration (assignment can come later). Below are a few examples of typecasting. 1 i n t i = 3 ; 2 double d = ( double ) i ; 3 char c = c ; 4 i n t a s c i i c = ( i n t ) c ; Remember: If you typecast you can lose information, for example if I typecast 6.8 to an integer I will get back Suggestions, Warnings, and Resources Warning: Make sure you use the correct ticks/quotes for variables. For example, to assign/initialize a char you must use (ticks or single quotes), to assign/initialize a String you must use (double quotes), and numbers don t use ticks or quotes. 2.3 FAQs 1. Q: Why is there an F or L at the end of a long or float value? Is it case sensitive? A: If you leave off the F when assigning or initializing a float, Java will assume you want a double (instead of a float). A float can hold 32-bit number and a double can hold a 64-bit number. You only need to add an L when assigning/initializing a long when the value won t fit into an int. An int can hold numbers between 2 31 and and a long can hold numbers between 2 63 and The F and the L are not case sensitive, but be careful a lower case l looks an awful like the number 1.
3 3 Printing So far you know of two ways to print to the console: System.out.print();, System.out.println();. Below is an example of how and when you could use each. 1 i n t num1 = 3 ; 2 i n t num2 = 5 ; 3 i n t num3 = 9 ; 4 double avg = (num1 + num2 + num3) / 3 ; 5 6 // The f o l l o w i n g t h r e e p r i n t statements are e q u i v a l e n t 7 System. out. p r i n t ( Average + num1 +, + num2 +, and + num3 + : + avg + \n ) ; 8 System. out. p r i n t l n ( Average + num1 +, + num2 +, and + num3 + : + avg ) ; This outputs the following: Average 3, 5, and 9: 5.0 Average 3, 5, and 9: 5.0 System.out.print(); is the same as System.out.println(); except it doesn t have a new line character at the end of the line. 3.1 FAQs 1. Q: Can you use either print or println to print? Is there a specific time you d use one over the other? A: You can use either to print at any time, however, one might be easier in some situations over the other. 4 Conditional Statements 4.1 if-else if-else Statements 1 p u b l i c c l a s s C o n d i t i o n a l s { 2 p u b l i c s t a t i c void main ( S t r i n g [ ] a r g s ) { 3 i n t i = 0 ; 4 // i f statement 5 i f ( i == 0) { 6 System. out. p r i n t l n ( i == 0 ) ; 7 } 8 boolean b = t r u e ; 9 // I don t need b r a c k e t s because I only have one l i n e o f code 10 // under each statement. However, you can always have b r a c k e t s 11 // l i k e the example above. 12 i f ( b == f a l s e ) 13 System. out. p r i n t l n ( b i s FALSE ) ; 14 e l s e 15 System. out. p r i n t l n ( b i s TRUE ) ; i n t i 1 = 3 2 ; 18 // here I do need b r a c k e t s because t h e r e i s more than one 19 // l i n e o f code nested i n my i f statement. 20 i f ( i 1 >= 15) { 21 System. out. p r i n t l n ( i 1 i s g r e a t e r than or equal to 15 ) ; 22 i 1 ++; 23 } 24 e l s e i f ( i < 3) 25 System. out. p r i n t l n ( i i s l e s s than 3 ) ; 26 // e l s e s are l i k e catch a l l s t h e r e are a s e c t i o n o f numbers 27 // that aren t covered by my i f and e l s e i f so my e l s e w i l l 28 // handle t h o s e v a l u e s 29 e l s e 30 System. out. p r i n t l n ( i must be between 3 and 14 ) ; // sometimes you don t need an e l s e 33 S t r i n g name = Waldo ; 34 // i f I have found Waldo I want to say I found him but...
4 35 i f ( name. e q u a l s ( Waldo ) ) 36 System. out. p r i n t l n ( Found him! ) ; 37 // i f I didn t f i n d him I don t want to do anything 38 } 39 } The output from the above code is: i == 0 b is TRUE i1 is greater than or equal to 15 Found him! 4.2 Difference between if-if-if and if-else if-else If you use an if-else if-else statement and multiple conditionals are true, the program executes the first true conditional and then exits. If you use an if-if-if statement and multiple conditionals are true, the program will execute all of the true conditionals. 1 p u b l i c c l a s s C o n d i t i o n a l s { 2 p u b l i c s t a t i c void main ( S t r i n g [ ] a r g s ) { 3 i n t i = ; 4 System. out. p r i n t l n ( i f e l s e i f e l s e statement ) ; 5 i f ( i == 128) 6 System. out. p r i n t l n ( i == 128 ) ; 7 e l s e i f ( i > 100) 8 System. out. p r i n t l n ( i > 100 ) ; 9 e l s e i f ( i < 130) 10 System. out. p r i n t l n ( i < 130 ) ; System. out. p r i n t l n ( i f i f i f statement ) ; i f ( i == 128) 15 System. out. p r i n t l n ( i == 128 ) ; 16 i f ( i > 100) 17 System. out. p r i n t l n ( i > 100 ) ; 18 i f ( i < 130) 19 System. out. p r i n t l n ( I < 130 ) ; 20 } 21 } The output from the above code is: if-else if-else statement i == 128 if-if-if statement i == 128 i > 100 I < Switch Statements 1 p u b l i c c l a s s C o n d i t i o n a l s { 2 p u b l i c s t a t i c void main ( S t r i n g [ ] a r g s ) { 3 i n t i = 3 2 ; 4 switch ( i ) { 5 c a s e 1 0 : System. out. p r i n t l n ( i = 10 ) ; break ; 6 c a s e 3 2 : System. out. p r i n t l n ( i = 32 ) ; break ; 7 c a s e : System. out. p r i n t l n ( i = 101 ) ; break ; 8 d e f a u l t : System. out. p r i n t l n ( i i s not 10, 32, or 101 ) ; 9 } // beware o f your breaks! 12 char c = b ;
5 13 switch ( c ) { 14 c a s e a : System. out. p r i n t l n ( c = a ) ; 15 c a s e b : System. out. p r i n t l n ( c = b ) ; 16 c a s e c : System. out. p r i n t l n ( c = c ) ; 17 d e f a u l t : System. out. p r i n t l n ( c i s not a, b, or c ) ; 18 } // times you might want to not have breaks 21 i n t dogs = 0, c a t s = 0 ; 22 S t r i n g breed = German Shepard ; // s p a c i n g doesn t matter 25 // you aren t r e q u i r e d to have a d e f a u l t 26 // l i k e you aren t r e q u i r e d to have an e l s e 27 // j u s t be aware that t h e r e are p o s s i b l e c a s e s 28 // that aren t being handled. 29 switch ( breed ) { 30 c a s e Boxer : 31 c a s e Great Dane : 32 c a s e German Shepard : 33 c a s e Lab : 34 dogs++; break ; c a s e C a l i c o : c a s e B r i t i s h S h o r t h a i r : c a s e Siamese : 37 c a t s ++; break ; 38 } 39 System. out. p r i n t l n ( Dogs : + dogs +, Cats + c a t s ) ; 40 } 41 } The output from the above code is: i = 32 c = b c = c c is not a, b, or c Dogs: 1, Cats Suggestions, Warnings, and Resources Warning: Don t add a semicolon after your conditional. For example if (32 == 32);. Warning: Be aware of when you should and shouldn t have breaks in your switch statement. 5 Scanners Below is an example of reading from the keyboard/console. 1 // importing n e c e s s a r y methods 2 import java. u t i l. Scanner ; 3 4 p u b l i c c l a s s S c a n n e r P r a c t i c e { 5 p u b l i c s t a t i c void main ( S t r i n g [ ] a r g s ) { 6 // I n i t i a l i z e s a Scanner o b j e c t c a l l e d r e a d e r 7 Scanner r e a d e r = new Scanner ( System. i n ) ; 8 // Prompting u s e r f o r an i n t e g e r 9 System. out. p r i n t ( Enter your f a v o r i t e i n t e g e r : ) ; 10 // Read and s t o r e an i n t 11 i n t f a v o r i t e n u m b e r = r e a d e r. n e x t I n t ( ) ; 12 // Prompting u s e r f o r a decimal 13 System. out. p r i n t ( Enter your f a v o r i t e decimal number : ) ; 14 // Read and s t o r e a double 15 double f a v o r i t e d e c i m a l = r e a d e r. nextdouble ( ) ; 16 // p r i n t i n g summary 17 System. out. p r i n t l n ( Your f a v o r i t e i n t e g e r i s + f a v o r i t e n u m b e r + \nyour f a v o r i t e decimal number i s + f a v o r i t e d e c i m a l ) ; 18 r e a d e r. c l o s e ( ) ;
6 19 } 20 } On the console, it looks like this: Enter your favorite integer: 3 Enter your favorite decimal number: 3.14 Your favorite integer is 3 Your favorite decimal number is Suggestions, Warnings, and Resources Suggestion: Get in the habit of closing your Scanners Resource: Use Oracle s documentation for more methods and examples 5.2 FAQs 1. Q: My code still works even though I didn t close my Scanner object, why do you guys teach so you have to close it? A: We teach it so you close your Scanners so you get in the habit of closing objects (better coding practice and when we get to PrintWriters you must close your object).
7 6 Practice Written Exam 6.1 Short Answer 1. Declare an integer named i0. 2. Initialize a float named f to Initialize a Scanner to read from the keyboard, called read. 4. Assign i0 to an integer entered from the user. 5. Close the Scanner. 6. Name the eight primitive types. 7. What is 18 % 3? 8. Write a switch statement based off of the character variable c. If c is a print hi, if c is b print okay, if c is c print then, if c is d print bye, if it is not a, b, c, or d print fine then. 9. Write an if statement that does the same thing as question Declare a Scanner called scan. Read in one int and store it into the predefined int variable called my int. Close your scanner.
8 6.2 Tracing Code For each question below, write what is printed. 1 import java. u t i l. Scanner ; 2 3 p u b l i c c l a s s Tracing { 4 p u b l i c s t a t i c void main ( S t r i n g [ ] a r g s ) { 5 i n t i = 3 ; 6 double d = ( double ) i ; 7 // Question 1 8 System. out. p r i n t l n ( i + + d ) ; 9 10 Scanner keys = new Scanner ( System. i n ) ; 11 d = keys. n e x t I n t ( ) ; 12 i = ( i n t ) keys. nextdouble ( ) ; // Question 2 ( assume the u s e r e n t e r s 8 and r e s p e c t i v e l y ) 15 System. out. p r i n t l n ( i + + d ) ; S t r i n g r e s u l t = i n i t i a l r e s u l t ; i f ( d > 98) 20 r e s u l t = g r e a t e r than 98 ; 21 e l s e 22 r e s u l t = l e s s than or equal to 98 ; 23 System. out. p r i n t l n ( r e s u l t ) ; char grade = a ; 26 // Question 3 27 switch ( grade ) { 28 c a s e a : System. out. p r i n t l n ( Passing! ) ; 29 c a s e b : System. out. p r i n t l n ( Passing! ) ; 30 c a s e c : System. out. p r i n t l n ( Passing! ) ; 31 c a s e d : System. out. p r i n t l n ( Kinda s o r t a p a s s i n g ) ; 32 c a s e f : System. out. p r i n t l n ( Not r e a l l y p a s s i n g ) ; 33 d e f a u l t : System. out. p r i n t l n ( Not a grade l e t t e r r e c o g n i z e d ) ; 34 } 35 } 36 }
9 7 Programming Quiz Practice Exam 1. Create a class with a main method 2. Import the Scanner class 3. Create an int variable called age 4. Prompt the user to enter their age 5. Using the Scanner read in their age and assign the value to age 6. Write a conditional statement that prints the following under these conditions: if their age is 16 or older print You can drive! if their age is 18 or older print You can vote! if their age is 21 or older print You can drink! if their age is 25 or older print You can rent a car! 7. Close reader An example run would look like: Enter your age: 25 You can drive! You can vote! You can drink! You can rent a car! 8 Suggestions for Studying and Test Taking 8.1 Written When reading through code and writing the output: Write your variables on the side and as your variables change, you change your list on the side. Practice writing code in Eclipse and before you run your program guess what the output would be. is good practice for testing your own programs and also for the code tracing part of the exam. This If you need more tracing examples (or more coding examples in general), there is a Programs tab on the CS150 homepage. There are also examples on the Progress page. 8.2 Programming Quiz Go back to past recitations and assignments and redo them without using the INTERNET, friends, or past recitations/assignments. Practice writing code in Eclipse. Make up projects and problems or ask a TA and they can give you some challenges. Look at code, the more exposure you get to code (whether it s your own code or not) the easier it is to understand. Some sample code is under the Programs tab and the Progress Page. 8.3 Common Errors Incorrect brackets around conditional statements 8.4 Challenges CodingBat and Hackerrank offer good extra coding practice.
10 ANSWERS ON THE NEXT PAGE
11 9 Answers to Practice Written and Programming Problems 9.1 Written Short Answer 1. int i0; 2. float f = 4.0F; 3. Scanner read = new Scanner(System.in); 4. i0 = read.nextint(); 5. read.close(); 6. int, double, char, float, long, boolean, byte switch ( c ) { 2 c a s e a : System. out. p r i n t l n ( h i ) ; break ; 3 c a s e b : System. out. p r i n t l n ( okay ) ; break ; 4 c a s e c : System. out. p r i n t l n ( then ) ; break ; 5 c a s e d : System. out. p r i n t l n ( bye ) ; break ; 6 d e f a u l t : System. out. p r i n t l n ( f i n e then ) ; break ; 7 } 9.1 i f ( c == a ) 2 System. out. p r i n t l n ( h i ) ; 3 e l s e i f ( c == b ) 4 System. out. p r i n t l n ( okay ) ; 5 e l s e i f ( c == c ) 6 System. out. p r i n t l n ( then ) ; 7 e l s e i f ( c == d ) 8 System. out. p r i n t l n ( bye ) ; 9 e l s e 10 System. out. p r i n t l n ( f i n e then ) ; Scanner scan = new Scanner ( System. i n ) ; 2 my int = scan. n e x t I n t ( ) ; 3 scan. c l o s e ( ) ; Tracing less than or equal to Passing! Passing! Passing! Kinda sorta passing Not really passing Not a grade letter recognized
12 9.2 Programming NOTE: Your solution may be different from the code below, as long as your output matches my output (in all cases), you are answer is fine. 1 import java. u t i l. Scanner ; 2 3 p u b l i c c l a s s PracticeProgramming { 4 p u b l i c s t a t i c void main ( S t r i n g [ ] a r g s ) { 5 Scanner r e a d e r = new Scanner ( System. i n ) ; 6 i n t age ; 7 8 System. out. p r i n t ( Enter your age : ) ; 9 age = r e a d e r. n e x t I n t ( ) ; i f ( age >= 16) 12 System. out. p r i n t l n ( You can d r i v e! ) ; 13 i f ( age >= 18) 14 System. out. p r i n t l n ( You can vote! ) ; 15 i f ( age >= 21) 16 System. out. p r i n t l n ( You can drink! ) ; 17 i f ( age >= 25) 18 System. out. p r i n t l n ( You can r e n t a car! ) ; r e a d e r. c l o s e ( ) ; 21 } 22 }
CS 163/164 - Exam 1 Study Guide and Practice Exam
CS 163/164 - Exam 1 Study Guide and Practice Exam September 11, 2017 Summary 1 Disclaimer 2 Variables 2.1 Primitive Types.............................................. 2.2 Strings...................................................
More informationCS Exam 3 Study Guide and Practice Exam
CS 163 - Exam 3 Study Guide and Practice Exam November 6, 2017 Summary 1 Disclaimer 2 Methods and Data 2.1 Static vs. Non-Static........................................... 2.1.1 Static Example..........................................
More information1. Write a program to calculate distance traveled by light
G. H. R a i s o n i C o l l e g e O f E n g i n e e r i n g D i g d o h H i l l s, H i n g n a R o a d, N a g p u r D e p a r t m e n t O f C o m p u t e r S c i e n c e & E n g g P r a c t i c a l M a
More informationTake-home Lab 1. Arrays
Take-home Lab 1 Arrays Findx 2-Dimensional Array Graded! Submit by Friday 23:59 Find You are given a treasure map by your friend Map is divided into R by C cells Super Marks The Spot You need to find all
More informationITI Introduction to Computing II
(with contributions from R. Holte) School of Electrical Engineering and Computer Science University of Ottawa Version of January 11, 2015 Please don t print these lecture notes unless you really need to!
More informationITI Introduction to Computing II
(with contributions from R. Holte) School of Electrical Engineering and Computer Science University of Ottawa Version of January 9, 2019 Please don t print these lecture notes unless you really need to!
More informationSolution to Proof Questions from September 1st
Solution to Proof Questions from September 1st Olena Bormashenko September 4, 2011 What is a proof? A proof is an airtight logical argument that proves a certain statement in general. In a sense, it s
More informationIntroduction to Computer Programming, Spring Term 2018 Practice Assignment 1 Discussion:
German University in Cairo Media Engineering and Technology Prof. Dr. Slim Abdennadher Dr. Rimon Elias Dr. Hisham Othman Introduction to Computer Programming, Spring Term 2018 Practice Assignment 1 Discussion:
More informationC if U can. Algebra. Name
C if U can Algebra Name.. How will this booklet help you to move from a D to a C grade? The topic of algebra is split into six units substitution, expressions, factorising, equations, trial and improvement
More informationQuadratic Equations Part I
Quadratic Equations Part I Before proceeding with this section we should note that the topic of solving quadratic equations will be covered in two sections. This is done for the benefit of those viewing
More informationbase 2 4 The EXPONENT tells you how many times to write the base as a factor. Evaluate the following expressions in standard notation.
EXPONENTIALS Exponential is a number written with an exponent. The rules for exponents make computing with very large or very small numbers easier. Students will come across exponentials in geometric sequences
More informationComputer 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 informationAlgebra. 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 informationIntroduction to Computer Programming, Spring Term 2018 Practice Assignment 1 Discussion:
German University in Cairo Media Engineering and Technology Prof. Dr. Slim Abdennadher Dr. Mohammed Abdel Megeed Introduction to Computer Programming, Spring Term 2018 Practice Assignment 1 Discussion:
More informationUnit 7 Graphs and Graphing Utilities - Classwork
A. Graphing Equations Unit 7 Graphs and Graphing Utilities - Classwork Our first job is being able to graph equations. We have done some graphing in trigonometry but now need a general method of seeing
More informationUnit 8: Sequ. ential Circuits
CPSC 121: Models of Computation Unit 8: Sequ ential Circuits Based on slides by Patrice Be lleville and Steve Wolfman Pre-Class Learning Goals By the start of class, you s hould be able to Trace the operation
More informationLesson 21 Not So Dramatic Quadratics
STUDENT MANUAL ALGEBRA II / LESSON 21 Lesson 21 Not So Dramatic Quadratics Quadratic equations are probably one of the most popular types of equations that you ll see in algebra. A quadratic equation has
More informationCOLLEGE ALGEBRA. Solving Equations and Inequalities. Paul Dawkins
COLLEGE ALGEBRA Solving Equations and Inequalities Paul Dawkins Table of Contents Preface... ii Solving Equations and Inequalities... 3 Introduction... 3 s and Sets... 4 Linear Equations... 8 Application
More informationIntroduction to Computer Programming, Spring Term 2018 Practice Assignment 3 Discussion:
German University in Cairo Media Engineering and Technology Prof. Dr. Slim Abdennadher Dr. Mohammed Abdel Megeed Introduction to Computer Programming, Spring Term 2018 Practice Assignment 3 Discussion:
More informationInference and Proofs (1.6 & 1.7)
EECS 203 Spring 2016 Lecture 4 Page 1 of 9 Introductory problem: Inference and Proofs (1.6 & 1.7) As is commonly the case in mathematics, it is often best to start with some definitions. An argument for
More informationLecture 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 informationMath 3361-Modern Algebra Lecture 08 9/26/ Cardinality
Math 336-Modern Algebra Lecture 08 9/26/4. Cardinality I started talking about cardinality last time, and you did some stuff with it in the Homework, so let s continue. I said that two sets have the same
More informationAt the end of the exam you must copy that folder onto a USB stick. Also, you must your files to the instructor.
Before you begin your work, please create a new file folder on your computer. The name of the folder should be YourLastName_YourFirstName For example, if your name is John Smith your folder should be named
More informationAlgebra 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 informationCh. 3 Equations and Inequalities
Ch. 3 Equations and Inequalities 3.1 Solving Linear Equations Graphically There are 2 methods presented in this section for solving linear equations graphically. Normally I would not cover solving linear
More informationFIT100 Spring 01. Project 2. Astrological Toys
FIT100 Spring 01 Project 2 Astrological Toys In this project you will write a series of Windows applications that look up and display astrological signs and dates. The applications that will make up the
More informationE40M. Binary Numbers. M. Horowitz, J. Plummer, R. Howe 1
E40M Binary Numbers M. Horowitz, J. Plummer, R. Howe 1 Reading Chapter 5 in the reader A&L 5.6 M. Horowitz, J. Plummer, R. Howe 2 Useless Box Lab Project #2 Adding a computer to the Useless Box alows us
More informationIntroduction to Programming (Java) 3/12
Introduction to Programming (Java) 3/12 Michal Krátký Department of Computer Science Technical University of Ostrava Introduction to Programming (Java) 2008/2009 c 2006 2008 Michal Krátký Introduction
More informationLiquid-in-glass thermometer
Objectives Liquid-in-glass thermometer The objectives of this experiment is to introduce some basic concepts in measurement, and to develop good measurement habits. In the first section, we will develop
More informationCSE 331 Winter 2018 Reasoning About Code I
CSE 331 Winter 2018 Reasoning About Code I Notes by Krysta Yousoufian Original lectures by Hal Perkins Additional contributions from Michael Ernst, David Notkin, and Dan Grossman These notes cover most
More informationAdam Blank Spring 2017 CSE 311. Foundations of Computing I. * All slides are a combined effort between previous instructors of the course
Adam Blank Spring 2017 CSE 311 Foundations of Computing I * All slides are a combined effort between previous instructors of the course HW 3 De-Brief HW 3 De-Brief PROOFS! HW 3 De-Brief Proofs This is
More informationQ: How can quantum computers break ecryption?
Q: How can quantum computers break ecryption? Posted on February 21, 2011 by The Physicist Physicist: What follows is the famous Shor algorithm, which can break any RSA encryption key. The problem: RSA,
More informationCOLLEGE ALGEBRA. Paul Dawkins
COLLEGE ALGEBRA Paul Dawkins Table of Contents Preface... iii Outline... iv Preliminaries... 7 Introduction... 7 Integer Exponents... 8 Rational Exponents...5 Radicals... Polynomials...30 Factoring Polynomials...36
More informationCS 360, Winter Morphology of Proof: An introduction to rigorous proof techniques
CS 30, Winter 2011 Morphology of Proof: An introduction to rigorous proof techniques 1 Methodology of Proof An example Deep down, all theorems are of the form If A then B, though they may be expressed
More informationCOMS 6100 Class Notes
COMS 6100 Class Notes Daniel Solus September 20, 2016 1 General Remarks The Lecture notes submitted by the class have been very good. Integer division seemed to be a common oversight when working the Fortran
More informationNumber Systems. There are 10 kinds of people those that understand binary, those that don t, and those that expected this joke to be in base 2
Number Systems There are 10 kinds of people those that understand binary, those that don t, and those that expected this joke to be in base 2 A Closer Look at the Numbers We Use What is the difference
More informationDo NOT rely on this as your only preparation for the Chem 101A final. You will almost certainly get a bad grade if this is all you look at.
Do NOT rely on this as your only preparation for the Chem 101A final. You will almost certainly get a bad grade if this is all you look at. This is an INCOMPLETE list of hints and topics for the Chem 101
More informationCompA - Complex Analyzer
CompA - Complex Analyzer Xiping Liu(xl2639), Jianshuo Qiu(jq2253), Tianwu Wang(tw2576), Yingshuang Zheng(yz3083), Zhanpeng Su(zs2329) Septembee 25, 2017 1 Introduction The motivation for writing this language
More informationLiquid-in-glass thermometer
Liquid-in-glass thermometer Objectives The objective of this experiment is to introduce some basic concepts in measurement, and to develop good measurement habits. In the first section, we will develop
More informationObject Oriented Software Design (NTU, Class Even, Spring 2009) Final Examination Problem Sheet TIME: 06/16/2009, 14:20 17:20
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
More informationMath101, 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 informationCISC 4090: Theory of Computation Chapter 1 Regular Languages. Section 1.1: Finite Automata. What is a computer? Finite automata
CISC 4090: Theory of Computation Chapter Regular Languages Xiaolan Zhang, adapted from slides by Prof. Werschulz Section.: Finite Automata Fordham University Department of Computer and Information Sciences
More informationC++ For Science and Engineering Lecture 13
C++ For Science and Engineering Lecture 13 John Chrispell Tulane University Wednesday September 22, 2010 Logical Expressions: Sometimes you want to use logical and and logical or (even logical not) in
More informationCALCULUS I. Review. Paul Dawkins
CALCULUS I Review Paul Dawkins Table of Contents Preface... ii Review... 1 Introduction... 1 Review : Functions... Review : Inverse Functions...1 Review : Trig Functions...0 Review : Solving Trig Equations...7
More informationCalculus II. Calculus II tends to be a very difficult course for many students. There are many reasons for this.
Preface Here are my online notes for my Calculus II course that I teach here at Lamar University. Despite the fact that these are my class notes they should be accessible to anyone wanting to learn Calculus
More informationCHM 105 & 106 UNIT 2, LECTURE SEVEN 1 IN OUR PREVIOUS LECTURE WE WERE TALKING ABOUT THE DYNAMICS OF DISSOLVING AND WE
CHM 105 & 106 UNIT 2, LECTURE SEVEN 1 CHM 105/106 Program 14: Unit 2 Lecture 7 IN OUR PREVIOUS LECTURE WE WERE TALKING ABOUT THE DYNAMICS OF DISSOLVING AND WE WERE TALKING ABOUT PARTICLES GAINING ENERGY
More informationMath 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 informationCSE 311: Foundations of Computing. Lecture 26: Cardinality
CSE 311: Foundations of Computing Lecture 26: Cardinality Cardinality and Computability Computers as we know them grew out of a desire to avoid bugs in mathematical reasoning A brief history of reasoning
More informationIntroduction to Computational Complexity
Introduction to Computational Complexity Tandy Warnow October 30, 2018 CS 173, Introduction to Computational Complexity Tandy Warnow Overview Topics: Solving problems using oracles Proving the answer to
More informationWhat are binary numbers and why do we use them? BINARY NUMBERS. Converting decimal numbers to binary numbers
What are binary numbers and why do we use them? BINARY NUMBERS Converting decimal numbers to binary numbers The number system we commonly use is decimal numbers, also known as Base 10. Ones, tens, hundreds,
More informationCS 7B - Spring Assignment: Adapting the calculator for bitwise expressions. due 2/21/18
CS 7B - Spring 2018 - Assignment: Adapting the calculator for bitwise expressions. due 2/21/18 Background Theory A bitwise number is a number in base 2. In base 2, place values are either a 1 or 0, depending
More informationLab Exercise 6 CS 2334
Lab Exercise 6 CS 2334 September 28, 2017 Introduction In this lab, you will experiment with using inheritance in Java through the use of abstract classes and interfaces. You will implement a set of classes
More informationof 8 28/11/ :25
Paul's Online Math Notes Home Content Chapter/Section Downloads Misc Links Site Help Contact Me Differential Equations (Notes) / First Order DE`s / Modeling with First Order DE's [Notes] Differential Equations
More informationSolving Equations by Adding and Subtracting
SECTION 2.1 Solving Equations by Adding and Subtracting 2.1 OBJECTIVES 1. Determine whether a given number is a solution for an equation 2. Use the addition property to solve equations 3. Determine whether
More informationCS 170 Algorithms Spring 2009 David Wagner Final
CS 170 Algorithms Spring 2009 David Wagner Final PRINT your name:, (last) SIGN your name: (first) PRINT your Unix account login: Your TA s name: Name of the person sitting to your left: Name of the person
More informationTuring Machines Part Three
Turing Machines Part Three What problems can we solve with a computer? What kind of computer? Very Important Terminology Let M be a Turing machine. M accepts a string w if it enters an accept state when
More informationCHM 105 & 106 MO1 UNIT TWO, LECTURE THREE 1 IN OUR PREVIOUS LECTURE WE TALKED ABOUT USING CHEMICAL EQUATIONS TO SHOW THE
CHM 105 & 106 MO1 UNIT TWO, LECTURE THREE 1 CHM 105/106 Program 10: Unit 2 Lecture 3 IN OUR PREVIOUS LECTURE WE TALKED ABOUT USING CHEMICAL EQUATIONS TO SHOW THE LAW OF MASS AND THE LAW OF CONSERVATION
More informationCS177 Spring Midterm 2. April 02, 8pm-9pm. There are 25 multiple choice questions. Each one is worth 4 points.
CS177 Spring 2015 Midterm 2 April 02, 8pm-9pm There are 25 multiple choice questions. Each one is worth 4 points. Answer the questions on the bubble sheet given to you. Only the answers on the bubble sheet
More information1 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 informationVectors Part 1: Two Dimensions
Vectors Part 1: Two Dimensions Last modified: 20/02/2018 Links Scalars Vectors Definition Notation Polar Form Compass Directions Basic Vector Maths Multiply a Vector by a Scalar Unit Vectors Example Vectors
More informationYou 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 informationWe introduce one more operation on sets, perhaps the most important
11. The power set Please accept my resignation. I don t want to belong to any club that will accept me as a member. Groucho Marx We introduce one more operation on sets, perhaps the most important one:
More informationLatches. October 13, 2003 Latches 1
Latches The second part of CS231 focuses on sequential circuits, where we add memory to the hardware that we ve already seen. Our schedule will be very similar to before: We first show how primitive memory
More informationPreptests 59 Answers and Explanations (By Ivy Global) Section 1 Analytical Reasoning
Preptests 59 Answers and Explanations (By ) Section 1 Analytical Reasoning Questions 1 5 Since L occupies its own floor, the remaining two must have H in the upper and I in the lower. P and T also need
More informationEXTRA CREDIT FOR MATH 39
EXTRA CREDIT FOR MATH 39 This is the second, theoretical, part of an extra credit homework. This homework in not compulsory. If you do it, you can get up to 6 points (3 points for each part) of extra credit
More informationGuide to Proofs on Sets
CS103 Winter 2019 Guide to Proofs on Sets Cynthia Lee Keith Schwarz I would argue that if you have a single guiding principle for how to mathematically reason about sets, it would be this one: All sets
More informationCS1800: Mathematical Induction. Professor Kevin Gold
CS1800: Mathematical Induction Professor Kevin Gold Induction: Used to Prove Patterns Just Keep Going For an algorithm, we may want to prove that it just keeps working, no matter how big the input size
More informationCSE 311: Foundations of Computing. Lecture 27: Undecidability
CSE 311: Foundations of Computing Lecture 27: Undecidability Last time: Countable sets A set is countable iff we can order the elements of as = {,,, Countable sets: N-the natural numbers Z - the integers
More informationWeek 2: Defining Computation
Computational Complexity Theory Summer HSSP 2018 Week 2: Defining Computation Dylan Hendrickson MIT Educational Studies Program 2.1 Turing Machines Turing machines provide a simple, clearly defined way
More informationOutline. policies for the first part. with some potential answers... MCS 260 Lecture 10.0 Introduction to Computer Science Jan Verschelde, 9 July 2014
Outline 1 midterm exam on Friday 11 July 2014 policies for the first part 2 questions with some potential answers... MCS 260 Lecture 10.0 Introduction to Computer Science Jan Verschelde, 9 July 2014 Intro
More information6.001 Recitation 22: Streams
6.001 Recitation 22: Streams RI: Gerald Dalley, dalleyg@mit.edu, 4 May 2007 http://people.csail.mit.edu/dalleyg/6.001/sp2007/ The three chief virtues of a programmer are: Laziness, Impatience and Hubris
More informationChapter 20. Countability The rationals and the reals. This chapter covers infinite sets and countability.
Chapter 20 Countability This chapter covers infinite sets and countability. 20.1 The rationals and the reals You re familiar with three basic sets of numbers: the integers, the rationals, and the reals.
More information6th Grade. Equations & Inequalities.
1 6th Grade Equations & Inequalities 2015 12 01 www.njctl.org 2 Table of Contents Equations and Identities Tables Determining Solutions of Equations Solving an Equation for a Variable Click on a topic
More informationUnits and Dimensionality
Chapter 1 Units and Dimensionality If somebody asked me how tall I am, I might respond 1.78. But what do I mean by that? 1.78 feet? 1.78 miles? In fact, my height is 1.78 meters. Most physical measurements
More informationn CS 160 or CS122 n Sets and Functions n Propositions and Predicates n Inference Rules n Proof Techniques n Program Verification n CS 161
Discrete Math at CSU (Rosen book) Sets and Functions (Rosen, Sections 2.1,2.2, 2.3) TOPICS Discrete math Set Definition Set Operations Tuples 1 n CS 160 or CS122 n Sets and Functions n Propositions and
More informationEssential facts about NP-completeness:
CMPSCI611: NP Completeness Lecture 17 Essential facts about NP-completeness: Any NP-complete problem can be solved by a simple, but exponentially slow algorithm. We don t have polynomial-time solutions
More informationCS 221 Lecture 9. Tuesday, 1 November 2011
CS 221 Lecture 9 Tuesday, 1 November 2011 Some slides in this lecture are from the publisher s slides for Engineering Computation: An Introduction Using MATLAB and Excel 2009 McGraw-Hill Today s Agenda
More informationProblem 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 informationSquaring 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 informationSFWR ENG 3S03: Software Testing
(Slide 1 of 69) Dr. Ridha Khedri Writing in Department of Computing and Software, McMaster University Canada L8S 4L7, Hamilton, Ontario Acknowledgments: Material based on [HT03] Unit Testing in Java with
More informationCS481F01 Prelim 2 Solutions
CS481F01 Prelim 2 Solutions A. Demers 7 Nov 2001 1 (30 pts = 4 pts each part + 2 free points). For this question we use the following notation: x y means x is a prefix of y m k n means m n k For each of
More informationChapter 6, Factoring from Beginning and Intermediate Algebra by Tyler Wallace is available under a Creative Commons Attribution 3.0 Unported license.
Chapter 6, Factoring from Beginning and Intermediate Algebra by Tyler Wallace is available under a Creative Commons Attribution 3.0 Unported license. 2010. 6.1 Factoring - Greatest Common Factor Objective:
More informationIntermediate Algebra. Gregg Waterman Oregon Institute of Technology
Intermediate Algebra Gregg Waterman Oregon Institute of Technology c 2017 Gregg Waterman This work is licensed under the Creative Commons Attribution 4.0 International license. The essence of the license
More informationNondeterministic finite automata
Lecture 3 Nondeterministic finite automata This lecture is focused on the nondeterministic finite automata (NFA) model and its relationship to the DFA model. Nondeterminism is an important concept in the
More informationAstronomy 102 Math Review
Astronomy 102 Math Review 2003-August-06 Prof. Robert Knop r.knop@vanderbilt.edu) For Astronomy 102, you will not need to do any math beyond the high-school alegbra that is part of the admissions requirements
More informationLab Slide Rules and Log Scales
Name: Lab Slide Rules and Log Scales [EER Note: This is a much-shortened version of my lab on this topic. You won t finish, but try to do one of each type of calculation if you can. I m available to help.]
More informationAutomata and Computability
Automata and Computability Fall 207 Alexis Maciel Department of Computer Science Clarkson University Copyright c 207 Alexis Maciel ii Contents Preface vii Introduction 2 Finite Automata 5 2. Turing Machines...............................
More informationPrealgebra. Edition 5
Prealgebra Edition 5 Prealgebra, Edition 5 2009, 2007, 2005, 2004, 2003 Michelle A. Wyatt (M A Wyatt) 2009, Edition 5 Michelle A. Wyatt, author Special thanks to Garry Knight for many suggestions for the
More informationCS 301. Lecture 18 Decidable languages. Stephen Checkoway. April 2, 2018
CS 301 Lecture 18 Decidable languages Stephen Checkoway April 2, 2018 1 / 26 Decidable language Recall, a language A is decidable if there is some TM M that 1 recognizes A (i.e., L(M) = A), and 2 halts
More informationMathematical Background
Chapter 1 Mathematical Background When we analyze various algorithms in terms of the time and the space it takes them to run, we often need to work with math. That is why we ask you to take MA 2250 Math
More informationMATH 22 FUNCTIONS: ORDER OF GROWTH. Lecture O: 10/21/2003. The old order changeth, yielding place to new. Tennyson, Idylls of the King
MATH 22 Lecture O: 10/21/2003 FUNCTIONS: ORDER OF GROWTH The old order changeth, yielding place to new. Tennyson, Idylls of the King Men are but children of a larger growth. Dryden, All for Love, Act 4,
More informationa. See the textbook for examples of proving logical equivalence using truth tables. b. There is a real number x for which f (x) < 0. (x 1) 2 > 0.
For some problems, several sample proofs are given here. Problem 1. a. See the textbook for examples of proving logical equivalence using truth tables. b. There is a real number x for which f (x) < 0.
More informationPhysics Motion Math. (Read objectives on screen.)
Physics 302 - Motion Math (Read objectives on screen.) Welcome back. When we ended the last program, your teacher gave you some motion graphs to interpret. For each section, you were to describe the motion
More informationSoftware Testing Lecture 2
Software Testing Lecture 2 Justin Pearson September 25, 2014 1 / 1 Test Driven Development Test driven development (TDD) is a way of programming where all your development is driven by tests. Write tests
More informationContinuity and One-Sided Limits
Continuity and One-Sided Limits 1. Welcome to continuity and one-sided limits. My name is Tuesday Johnson and I m a lecturer at the University of Texas El Paso. 2. With each lecture I present, I will start
More informationTou has been released!
Tou has been released! Shoot- em-up, heavy use of collision detection Much more open-ended than previous projects Easier than previous projects if you work smart Should help those of you combating the
More informationFinal Review Sheet. B = (1, 1 + 3x, 1 + x 2 ) then 2 + 3x + 6x 2
Final Review Sheet The final will cover Sections Chapters 1,2,3 and 4, as well as sections 5.1-5.4, 6.1-6.2 and 7.1-7.3 from chapters 5,6 and 7. This is essentially all material covered this term. Watch
More informationCSCI-141 Exam 1 Review September 19, 2015 Presented by the RIT Computer Science Community
CSCI-141 Exam 1 Review September 19, 2015 Presented by the RIT Computer Science Community http://csc.cs.rit.edu 1. Python basics (a) The programming language Python (circle the best answer): i. is primarily
More information6.080 / Great Ideas in Theoretical Computer Science Spring 2008
MIT OpenCourseWare http://ocw.mit.edu 6.080 / 6.089 Great Ideas in Theoretical Computer Science Spring 2008 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms.
More informationHomework Assignment 4 Root Finding Algorithms The Maximum Velocity of a Car Due: Friday, February 19, 2010 at 12noon
ME 2016 A Spring Semester 2010 Computing Techniques 3-0-3 Homework Assignment 4 Root Finding Algorithms The Maximum Velocity of a Car Due: Friday, February 19, 2010 at 12noon Description and Outcomes In
More information