Control Statements. if for while
|
|
- Lucas Mathews
- 5 years ago
- Views:
Transcription
1 Control Structures
2 Control Statements if for while
3 Control Statements if for while
4 This This is is called called the the initialization initialization statement statement and and is is performed performed before before the the loop loop starts. starts. This This is is called called the the step step or or increment increment and and is is performed performed at at the the end end of of each each loop loop iteration. iteration. for (int i = 0; i < N; i++) { This This is is called called the the loop loop condition condition or or termination termination condition. condition. The The loop loop will will check check whether whether this this statement statement is is true true before before each each iteration iteration of of the the loop. loop.
5 for (int i = 0; i < 3; i++) { println("baby"); println("whoa");
6 for (int i = 0; i < 3; i++) { println("baby"); println("whoa");
7 for (int i = 0; i < 3; i++) { println("baby"); println("whoa");
8 for (int i = 0; i < 3; i++) { println("baby"); println("whoa"); int i 0
9 for (int i = 0; i < 3; i++) { println("baby"); println("whoa"); int i 0
10 for (int i = 0; i < 3; i++) { println("baby"); println("whoa"); int i 0
11 for (int i = 0; i < 3; i++) { println("baby"); println("whoa"); int i 0 Baby
12 for (int i = 0; i < 3; i++) { println("baby"); println("whoa"); int i 0 Baby
13 for (int i = 0; i < 3; i++) { println("baby"); println("whoa"); int i 1 Baby
14 for (int i = 0; i < 3; i++) { println("baby"); println("whoa"); int i 1 Baby
15 for (int i = 0; i < 3; i++) { println("baby"); println("whoa"); int i 1 Baby
16 for (int i = 0; i < 3; i++) { println("baby"); println("whoa"); int i 1 Baby Baby
17 for (int i = 0; i < 3; i++) { println("baby"); println("whoa"); int i 1 Baby Baby
18 for (int i = 0; i < 3; i++) { println("baby"); println("whoa"); int i 2 Baby Baby
19 for (int i = 0; i < 3; i++) { println("baby"); println("whoa"); int i 2 Baby Baby
20 for (int i = 0; i < 3; i++) { println("baby"); println("whoa"); int i 2 Baby Baby
21 for (int i = 0; i < 3; i++) { println("baby"); println("whoa"); int i 2 Baby Baby Baby
22 for (int i = 0; i < 3; i++) { println("baby"); println("whoa"); int i 2 Baby Baby Baby
23 for (int i = 0; i < 3; i++) { println("baby"); println("whoa"); int i 3 Baby Baby Baby
24 for (int i = 0; i < 3; i++) { println("baby"); println("whoa"); int i 3 Baby Baby Baby
25 for (int i = 0; i < 3; i++) { println("baby"); println("whoa"); int i 3 Baby Baby Baby
26 for (int i = 0; i < 3; i++) { println("baby"); println("whoa"); int i 3 Baby Baby Baby Whoa
27 for (int i = 0; i < 3; i++) { println("baby"); println("whoa"); int i 3 Baby Baby Baby Whoa
28 for (int i = 5; i > 0; i--) { println(i + "..."); println("lift-off!"); Lift-off!
29 An Actual Rocket Launch (Start at 9:25)
30 T-31 Seconds: Handoff has occurred T-17 Seconds: Firing chain armed T-10 Seconds: Hydrogen burn T-0 Seconds: Liftoff! for (int i = 40; i > 0; i--) { println("t-" + i + "..."); println("lift-off!");
31 public void run() { /* Do the launch countdown! */ for (int i = 40; i > 0; i--) { println("t-" + i + " seconds."); /* Specific mission commands. */ if (i == 31) { println("handoff has occurred."); else if (i == 17) { println("firing chain is armed."); else if (i == 10) { println("hydrogen burn."); println("lift-off!");
32 public void run() { /* Do the launch countdown! */ for (int i = 40; i > 0; i--) { println("t-" + i + " seconds."); /* Specific mission commands. */ if (i == 31) { println("handoff has occurred."); else if (i == 17) { println("firing chain is armed."); else if (i == 10) { println("hydrogen burn."); println("lift-off!");
33 public void run() { /* Do the launch countdown! */ for (int i = 40; i > 0; i--) { println("t-" + i + " seconds."); /* Specific mission commands. */ if (i == 31) { println("handoff has occurred."); else if (i == 17) { println("firing chain is armed."); else if (i == 10) { println("hydrogen burn."); println("lift-off!");
34 Magic Numbers A magic number is a number written in a piece of code whose meaning cannot easily be deduced from context. double weight = 9.8 * (mass 14.3); Magic numbers are a Bad Thing; they make code harder to read.
35 Constants Not all variables actually vary. A constant is a name for a value that never changes. Syntax (defined outside of any method): private static final type name = value; By convention, constants are named in UPPER_CASE_WITH_UNDERSCORES to differentiate them from variables.
36 General Rules for Constants You can usually use 0 and 1 in loops without needing constants. When computing averages, it's fine to just use the number 2. Anything more complex than this should probably be made into a constant.
37 Time-Out for Announcements!
38 Friday Four Square! Today at 4:15PM, Outside Gates
39 Announcements Programming Assignment #1 due right now. Due on next Wednesday if using a late day. LaIR closed on Sunday but open on Monday. due on Sunday night. Programming Assignment #2 out today, due Friday, January 31 at 3:15PM. Play around with Java statements and control structures! Make some pretty pictures! Explore your creative potential!
40 Casual Dinner for Women in CS Next Wednesday, January 22 at 6:00PM on the fifth floor of the Gates building. Good food, great company, and everyone is invited! RSVP through link (sent out Tuesday).
41 Control Statements for if while
42 Control Statements for if while
43 The while Loop while (condition) { statements Checks condition before each iteration and executes statements if true. Does not check condition in the middle of the loop.
44 Example: int x = 15; while (x > 1) { x /= 2; println(x); while loop Based on slides by Mehran Sahami
45 Example: int x = 15; while (x > 1) { x /= 2; println(x); while loop Based on slides by Mehran Sahami
46 while loop Example: int x = 15; while (x > 1) { x /= 2; println(x); 15 int x Based on slides by Mehran Sahami
47 while loop Example: int x = 15; while (x > 1) { x /= 2; println(x); 15 int x Based on slides by Mehran Sahami
48 while loop Example: int x = 15; while (x > 1) { x /= 2; println(x); 15 int x Based on slides by Mehran Sahami
49 while loop Example: int x = 15; while (x > 1) { x /= 2; println(x); 7 int x Based on slides by Mehran Sahami
50 while loop Example: int x = 15; while (x > 1) { x /= 2; println(x); 7 int x Based on slides by Mehran Sahami
51 while loop Example: int x = 15; while (x > 1) { x /= 2; println(x); 7 int x 7 Based on slides by Mehran Sahami
52 while loop Example: int x = 15; while (x > 1) { x /= 2; println(x); 7 int x 7 Based on slides by Mehran Sahami
53 while loop Example: int x = 15; while (x > 1) { x /= 2; println(x); 7 int x 7 Based on slides by Mehran Sahami
54 while loop Example: int x = 15; while (x > 1) { x /= 2; println(x); 3 int x 7 Based on slides by Mehran Sahami
55 while loop Example: int x = 15; while (x > 1) { x /= 2; println(x); 3 int x 7 Based on slides by Mehran Sahami
56 while loop Example: int x = 15; while (x > 1) { x /= 2; println(x); 3 int x 7 3 Based on slides by Mehran Sahami
57 while loop Example: int x = 15; while (x > 1) { x /= 2; println(x); 3 int x 7 3 Based on slides by Mehran Sahami
58 while loop Example: int x = 15; while (x > 1) { x /= 2; println(x); 3 int x 7 3 Based on slides by Mehran Sahami
59 while loop Example: int x = 15; while (x > 1) { x /= 2; println(x); 1 int x 7 3 Based on slides by Mehran Sahami
60 while loop Example: int x = 15; while (x > 1) { x /= 2; println(x); 1 int x 7 3 Based on slides by Mehran Sahami
61 while loop Example: int x = 15; while (x > 1) { x /= 2; println(x); 1 int x Based on slides by Mehran Sahami
62 while loop Example: int x = 15; while (x > 1) { x /= 2; println(x); 1 int x Based on slides by Mehran Sahami
63 while loop Example: int x = 15; while (x > 1) { x /= 2; println(x); 1 int x Based on slides by Mehran Sahami
64 Greatest Common Divisors Given two integers a and b, the greatest common divisor (or gcd) of a and b is the largest number that divides a and b. Examples: The gcd of 12 and 8 is 4. The gcd of 100 and 10 is 10. The gcd of 137 and 42 is 1.
65 Euclid's Algorithm 45 35
66 Euclid's Algorithm 45 35
67 Euclid's Algorithm 10 35
68 Euclid's Algorithm 10 35
69 Euclid's Algorithm 10 5
70 Euclid's Algorithm 10 5
71 Euclid's Algorithm 45 35
72 Euclid's Algorithm To compute the gcd of a and b: If b = 0, the gcd is a. Otherwise: Divide a by b and obtain the remainder r. Set a equal to b and b equal to r. Repeat. This procedure was known to the Greeks as anthyphairesis; it's almost always referred to now as Euclid's algorithm. It is one of the oldest algorithms still in use today.
Friday Four Square! Today at 4:15PM, Outside Gates
Control Structures Announcements Programming Assignment #1 due right now. Due on next Wednesday if using a late day. Email due on Sunday night. Programming Assignment #2 out today, due Wednesday, January
More informationExpressions and Control Statements
Expressions and Control Statements Recap From Last Time Variables A variable is a location where a program can store information for later use. Each variable has three pieces of information associated
More informationControl Structures and Methods
Control Structures and Methods An Interesting Article For Newcomers in Silicon Valley, the Dream of Entrepreneurship Still Lives http://www.nytimes.com/2012/01/25/us/silicon-valley-newcomers-are-still-dreaming-big.html
More informationExpressions and Control Statements
Expressions and Control Statements Announcements Programming Assignment #1 Out: Karel the Robot: Due Friday, January 18 at 3:15 PM. Email: Due Sunday, January 20 at 11:59PM. Need help? Stop by the LaIR!
More informationStandard Version of Starting Out with C++, 4th Edition. Chapter 19 Recursion. Copyright 2003 Scott/Jones Publishing
Standard Version of Starting Out with C++, 4th Edition Chapter 19 Recursion Copyright 2003 Scott/Jones Publishing Topics 19.1 Introduction to Recursion 19.2 The Recursive Factorial Function 19.3 The Recursive
More informationProgramming Karel the Robot
Programming Karel the Robot Announcements Five Handouts Today: Honor Code Downloading Eclipse Running Karel Programs in Eclipse Programming Assignment #1 Submitting Programming Assignments Please only
More informationExpressions, Statements, and Control Structures
Expressions, Statements, and Control Structures Announcements Assignment 2 out, due next Wednesday, February 1. Explore the Java concepts we've covered and will be covering. Unleash your creative potential!
More informationCS 106A, Lecture 5 Booleans and Control Flow
CS 106A, Lecture 5 Booleans and Control Flow suggested reading: Java Ch. 3.4-4.6 This document is copyright (C) Stanford Computer Science and Marty Stepp, licensed under Creative Commons Attribution 2.5
More informationObjects and Graphics
Objects and Graphics One Last Thought on Loops... Looping Forever while loops iterate as long as their condition evaluates to true. A loop of the form while (true) will loop forever (unless something stops
More informationCSCE 110: Programming I
CSCE 110: Programming I Sample Questions for Exam #1 February 17, 2013 Below are sample questions to help you prepare for Exam #1. Make sure you can solve all of these problems by hand. For most of the
More informationCS 106B, Lecture 1 Introduction to C++
CS 106B, Lecture 1 Introduction to C++ reading: Programming Abstractions in C++, Chapters 1 & 2 This document is copyright (C) Stanford Computer Science and Ashley Marty Stepp, Taylor, licensed under Creative
More informationDrawing Geometrical Objects. Graphic courtesy of Eric Roberts
Methods Drawing Geometrical Objects Graphic courtesy of Eric Roberts Drawing Geometrical Objects Constructors new GRect( x, y, width, height) Creates a rectangle whose upper left corner is at (x, y) of
More informationCSE115 / CSE503 Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall Office hours:
CSE115 / CSE503 Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall alphonce@buffalo.edu Office hours: Tuesday 10:00 AM 12:00 PM * Wednesday 4:00 PM 5:00 PM Friday 11:00 AM 12:00 PM OR
More informationCS 106A, Lecture 7 Parameters and Return
CS 106A, Lecture 7 Parameters and Return suggested reading: Java Ch. 5.1-5.4 This document is copyright (C) Stanford Computer Science and Marty Stepp, licensed under Creative Commons Attribution 2.5 License.
More informationPublic-Service Announcements
Public-Service Announcements The Computer Science Undergraduate Association(CSUA) welcomes all students interested in computer science to join them at their Welcome BBQ on Saturday, 8/27 from 12-4pm at
More informationIntroduction to Java
Introduction to Java A Farewell to Karel Welcome to Java But First... A Brief History of Digital Computers Image credit: http://upload.wikimedia.org/wikipedia/commons/4/4e/eniac.jpg Programming in the
More informationTechnical Section. Lab 4 while loops and for loops. A. while Loops or for loops
Lab 4 while loops and for loops The purpose of this lab is to introduce you to the concept of a for loop, gain experience distinguishing between a while loop (which is a more general type of loop than
More informationCS1150 Principles of Computer Science Boolean, Selection Statements
CS1150 Principles of Computer Science Boolean, Selection Statements Yanyan Zhuang Department of Computer Science http://www.cs.uccs.edu/~yzhuang CS1150 Math Center https://www.uccs.edu/mathcenter/schedules
More informationPublic-Service Announcements
Public-Service Announcements "CSUA has a Welcome BBQ on Wednesday, 2 September at 7PM in the Woz. Open to anyone interested in computer science. Please drop by our office located in 311 Soda Hall" Last
More informationDescribing and Implementing Algorithms
Describing and Implementing Algorithms ECE2036 Lecture 1 ECE2036 Describing and Implementing Algorithms Spring 2016 1 / 19 What is an Algorithm? According to Wikipedia: An algorithm is a sequence of instructions,
More informationAQA Decision 1 Algorithms. Section 1: Communicating an algorithm
AQA Decision 1 Algorithms Section 1: Communicating an algorithm Notes and Examples These notes contain subsections on Flow charts Pseudo code Loops in algorithms Programs for the TI-83 graphical calculator
More informationIntroduction to Programming in C Department of Computer Science and Engineering\ Lecture No. #02 Introduction: GCD
Introduction to Programming in C Department of Computer Science and Engineering\ Lecture No. #02 Introduction: GCD In this session, we will write another algorithm to solve a mathematical problem. If you
More informationCS61C Machine Structures. Lecture 3 Introduction to the C Programming Language. 1/23/2006 John Wawrzynek. www-inst.eecs.berkeley.
CS61C Machine Structures Lecture 3 Introduction to the C Programming Language 1/23/2006 John Wawrzynek (www.cs.berkeley.edu/~johnw) www-inst.eecs.berkeley.edu/~cs61c/ CS 61C L03 Introduction to C (1) Administrivia
More information} Evaluate the following expressions: 1. int x = 5 / 2 + 2; 2. int x = / 2; 3. int x = 5 / ; 4. double x = 5 / 2.
Class #10: Understanding Primitives and Assignments Software Design I (CS 120): M. Allen, 19 Sep. 18 Java Arithmetic } Evaluate the following expressions: 1. int x = 5 / 2 + 2; 2. int x = 2 + 5 / 2; 3.
More informationObjects Revisited. An object is a combination of. State persistent information, and Behavior the ability to operate on that state.
Classes Some Quick Thoughts Objects Revisited An object is a combination of State persistent information, and Behavior the ability to operate on that state. GRect state: Position Size Color Is filled?
More informationYEAH Hours. January , 7-8 PM Jared Wolens
YEAH Hours January 23 2017, 7-8 PM Jared Wolens YEAH Hours? Held after each assignment is released Future dates to be scheduled soon Review + Assignment Tips Plan for today: lecture review, assignment
More informationCS 106A, Lecture 3 Problem-solving with Karel
CS 106A, Lecture 3 Problem-solving with Karel suggested reading: Karel, Ch. 5-6 This document is copyright (C) Stanford Computer Science and Marty Stepp, licensed under Creative Commons Attribution 2.5
More informationCS 221 Lecture. Tuesday, 11 October 2011
CS 221 Lecture Tuesday, 11 October 2011 "Computers in the future may weigh no more than 1.5 tons." - Popular Mechanics, forecasting the relentless march of science, 1949. Today s Topics 1. Announcements
More informationGenome Sciences 373 Genome Informa1cs. Quiz Sec1on #1 March 31, 2015
Genome Sciences 373 Genome Informa1cs Quiz Sec1on #1 March 31, 2015 About me, course logistics, etc. Matthew s contact info Email: mwsnyder@uw.edu Phone: 206-685-3720 Office hours: Mondays 2:00-3:00pm
More informationLoops / Repetition Statements
Loops / Repetition Statements Repetition statements allow us to execute a statement multiple times Often they are referred to as loops C has three kinds of repetition statements: the while loop the for
More informationFloating-point lab deadline moved until Wednesday Today: characters, strings, scanf Characters, strings, scanf questions clicker questions
Announcements Thursday Extras: CS Commons on Thursdays @ 4:00 pm but none next week No office hours next week Monday or Tuesday Reflections: when to use if/switch statements for/while statements Floating-point
More informationIntroduction to Java
Introduction to Java Announcements Programming Assignment #1 Out: Karel the Robot: Due Friday, January 18 at 3:15 PM. Email: Due Sunday, January 20 at 11:59PM. Section assignments given out on Tuesday;
More informationMathematical Logic Part One
Mathematical Logic Part One Question: How do we formalize the logic we've been using in our proofs? Where We're Going Propositional Logic (Today) Basic logical connectives. Truth tables. Logical equivalences.
More informationCSE115 / CSE503 Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall Office hours:
CSE115 / CSE503 Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall alphonce@buffalo.edu Office hours: Tuesday 10:00 AM 12:00 PM * Wednesday 4:00 PM 5:00 PM Friday 11:00 AM 12:00 PM OR
More informationSynonyms. Hostile. Chilly. Direct. Sharp
Graphs and Networks A Social Network Synonyms Hostile Slick Icy Direct Nifty Cool Abrupt Sharp Composed Chilly Chemical Bonds http://4.bp.blogspot.com/-xctbj8lkhqa/tjm0bonwbri/aaaaaaaaak4/-mhrbauohhg/s600/ethanol.gif
More informationAssignment 2: Welcome to Java!
CS106A Winter 2011-2012 Handout #12 January 23, 2011 Assignment 2: Welcome to Java! Based on a handout by Eric Roberts and Mehran Sahami Having helped Karel the Robot through the challenges of Assignment
More informationCS 106A, Lecture 14 Events and Instance Variables
CS 106A, Lecture 14 Events and Instance Variables Reading: Art & Science of Java, Ch. 10.1-10.4 This document is copyright (C) Stanford Computer Science and Marty Stepp, licensed under Creative Commons
More informationOther conditional and loop constructs. Fundamentals of Computer Science Keith Vertanen
Other conditional and loop constructs Fundamentals of Computer Science Keith Vertanen Overview Current loop constructs: for, while, do-while New loop constructs Get out of loop early: break Skip rest of
More informationGuide to Success I. in December)
Five-Minute Review 1. What are expression statements? Compound statements? 2. What is a scope? 3. What are conditional statements in Java? How about iterative statements? 4. In conditionals, why should
More informationPractice Midterm Examination
Nick Troccoli Practice Midterm CS 106A July 18, 2017 Practice Midterm Examination Midterm Time: Monday, July 24th, 7:00P.M. 9:00P.M. Midterm Location: Hewlett 200 Based on handouts by Mehran Sahami, Eric
More informationAssignment #1: and Karel the Robot Karel problems due: 3:15pm on Friday, October 4th due: 11:59pm on Sunday, October 6th
Mehran Sahami Handout #7 CS 06A September, 0 Assignment #: Email and Karel the Robot Karel problems due: :pm on Friday, October th Email due: :9pm on Sunday, October 6th Part I Email Based on a handout
More informationPractice Midterm Examination
Mehran Sahami Handout #28 CS106A October 23, 2013 Practice Midterm Examination Midterm Time: Tuesday, October 29th, 7:00P.M. 9:00P.M. Midterm Location (by last name): Last name starts with A-L: go to Dinkelspiel
More informationRecursion. CSCI 112: Programming in C
Recursion CSCI 112: Programming in C 1 What is recursion? Recursion looks at a large problem as a bunch of smaller versions of the same problem. 2 2 What is recursion? Recursion looks at a large problem
More informationSimple Java YEAH Hours. Brahm Capoor and Vrinda Vasavada
Simple Java YEAH Hours Brahm Capoor and Vrinda Vasavada What are YEAH hours? Held soon after each assignment is released Help you to get an early start on your assignments Future dates TBA Slides will
More informationMehran Sahami Handout #7 CS 106A September 24, 2014
Mehran Sahami Handout #7 CS 06A September, 0 Assignment #: Email/Survey and Karel the Robot Karel problems due: :pm on Friday, October rd Email and online survey due: :9pm on Sunday, October th Part I
More informationCS 106A, Lecture 14 Events and Instance Variables
CS 106A, Lecture 14 Events and Instance Variables Reading: Art & Science of Java, Ch. 10.1-10.4 This document is copyright (C) Stanford Computer Science and Marty Stepp, licensed under Creative Commons
More informationApplied Cryptography and Network Security
Applied Cryptography and Network Security William Garrison bill@cs.pitt.edu 6311 Sennott Square Lecture #8: RSA Didn t we learn about RSA last time? During the last lecture, we saw what RSA does and learned
More informationAdministrivia. Last modified: Fri Aug 25 10:59: CS61B: Lecture #2 1
Administrivia Please make sure you have obtained a Unix account. If you are a concurrent enrollment student not yet on our lists, please tell a TA sothatwecanhaveyouaddedtothoseeligibletoreceiveanaccount.
More informationLecture 2. CS118 Term planner. Refinement. Recall our first Java program. Program skeleton GCD. For your first seminar. For your second seminar
2 Lecture 2 CS118 Term planner For your first seminar Meet at CS reception Bring The Guide Bring your CS account details Finish the problem sheet in your own time Talk to each other about the questions
More informationScientific Computing
Scientific Computing Martin Lotz School of Mathematics The University of Manchester Lecture 1, September 22, 2014 Outline Course Overview Programming Basics The C++ Programming Language Outline Course
More informationArrays. Array Basics. Chapter 8 Spring 2017, CSUS. Chapter 8.1
Arrays Chapter 8 Spring 2017, CSUS Array Basics Chapter 8.1 1 Array Basics Normally, variables only have one piece of data associated with them An array allows you to store a group of items of the same
More informationCSE115 / CSE503 Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall Office hours:
CSE115 / CSE503 Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall alphonce@buffalo.edu Office hours: Tuesday 10:00 AM 12:00 PM * Wednesday 4:00 PM 5:00 PM Friday 11:00 AM 12:00 PM OR
More informationELEMENTARY NUMBER THEORY AND METHODS OF PROOF
CHAPTER 4 ELEMENTARY NUMBER THEORY AND METHODS OF PROOF Copyright Cengage Learning. All rights reserved. SECTION 4.8 Application: Algorithms Copyright Cengage Learning. All rights reserved. Application:
More informationCIT 590 Homework 6 Fractions
CIT 590 Homework 6 Fractions Purposes of this assignment: Get you started in Java and Eclipse Get you comfortable using objects in Java Start looking at some common object uses in Java. General Idea of
More informationI2204 ImperativeProgramming Semester: 1 Academic Year: 2018/2019 Credits: 5 Dr Antoun Yaacoub
Lebanese University Faculty of Science Computer Science BS Degree I2204 ImperativeProgramming Semester: 1 Academic Year: 2018/2019 Credits: 5 Dr Antoun Yaacoub I2204- Imperative Programming Schedule 08h00-09h40
More informationThroughout the semester: questions slides book programming review questions practice exam
Five-Minute Review 1. What are expression statements? Compound statements? 2. What is a scope? 3. What are conditional statements in Java? How about iterative statements? 4. In conditionals, why should
More informationObject-Oriented Programming
Object-Oriented Programming Casual Dinner for Women in CS Next Thursday, January 24 in Gates 219 at 6:00PM. Good food, great company, and everyone is invited! RSVP through email link (sent out earlier
More informationTypes of recursion. Structural vs. general recursion. Pure structural recursion. Readings: none. In this module: learn to use accumulative recursion
Types of recursion Readings: none. In this module: learn to use accumulative recursion learn to recognize generative recursion CS 135 Fall 2018 07: Types of recursion 1 Structural vs. general recursion
More informationSecurity and Privacy
Security and Privacy Outline for Today Iterators and Assignment 7 One final topic for the last assignment. Demo for Assignment 7. Security and Privacy A case study in privacy and security. Iterators To
More informationMemory Chris Piech CS106A, Stanford University. Piech, CS106A, Stanford University
Memory Chris Piech CS106A, Stanford University Learning Goals 1. Be able to trace memory with references Write this program Who thinks this prints true? Who thinks this prints true? public void run() {
More informationConditionals !
Conditionals 02-201! Computing GCD GCD Problem: Compute the greatest common divisor of two integers. Input: Two integers a and b. Output: The greatest common divisor of a and b. Exercise: Design an algorithm
More informationChapter 1 An Introduction to Computer Science. INVITATION TO Computer Science 1
Chapter 1 An Introduction to Computer Science INVITATION TO Computer Science 1 Q8. Under what conditions would the well-known quadratic formula not be effectively computable? (Assume that you are working
More informationCSE 113. Announcements
CSE 113 September 20, 2010 Lab 3 posted Announcements Grades for all labs are still not being computed because of problem with Web-CAT s grading module hopefully we will get to a resolution this week Exam
More information15-110: Principles of Computing, Spring Problem Set 3 (PS3) Due: Friday, February 9 by 2:30PM on Gradescope
15-110: Principles of Computing, Spring 2018 Problem Set 3 (PS3) Due: Friday, February 9 by 2:30PM on Gradescope HANDIN INSTRUCTIONS Download a copy of this PDF file. You have two ways to fill in your
More informationGuide to Success I. in December)
Five-Minute Review 1. What are expression statements? Compound statements? 2. What is a scope? 3. What are conditional statements in Java? How about iterative statements? 4. In conditionals, why should
More informationWhat is Java? professional software engineering.
Welcome Back! Welcome to Java! What is Java? Java is an industrial programming language used to build large applications. Used in web servers, Android phones, desktop applications, etc. Extremely common:
More informationMichele Van Dyne Museum 204B CSCI 136: Fundamentals of Computer Science II, Spring
Michele Van Dyne Museum 204B mvandyne@mtech.edu http://katie.mtech.edu/classes/csci136 CSCI 136: Fundamentals of Computer Science II, Spring 2016 1 Review of Java Basics Data Types Arrays NEW: multidimensional
More informationAdmin ENCRYPTION. Admin. Encryption 10/29/15. Assignment 6. 4 more assignments: Midterm next Thursday. What is it and why do we need it?
Admin Assignment 6 4 more assignments:! Assignment 7, due 11/13 5pm! Assignment 8, due 11/20 5pm! Assignments 9 & 10, due 12/9 11:59pm ENCRYPTION David Kauchak CS52 Spring 2015 Admin Midterm next Thursday!
More informationAlgorithms, Part 1 of 3. Problem Solving. Algorithms
Algorithms, Part 1 of 3 Topics Definition of an Algorithm Algorithm Examples Syntax versus Semantics Reading Sections 3.1-3.3 Problem Solving Problem solving is the process of transforming the description
More informationCISC-124. Dog.java looks like this. I have added some explanatory comments in the code, and more explanation after the code listing.
CISC-124 20180115 20180116 20180118 We continued our introductory exploration of Java and object-oriented programming by looking at a program that uses two classes. We created a Java file Dog.java and
More informationCS111: PROGRAMMING LANGUAGE II
CS111: PROGRAMMING LANGUAGE II Computer Science Department Lecture 1(c): Java Basics (II) Lecture Contents Java basics (part II) Conditions Loops Methods Conditions & Branching Conditional Statements A
More informationAlgorithms, Part 1 of 3
Algorithms, Part 1 of 3 Topics Definition of an Algorithm Algorithm Examples Syntax versus Semantics 1 Problem Solving Problem solving is the process of transforming the description of a problem into the
More informationHomework Assignment 2: Java Console and Graphics
SSEA August 2016 Cynthia Lee CS106A Homework Assignment 2: Java Console and Graphics Based on past assignments created by Marty Stepp, Mehran Sahami, Keith Schwarz, Eric Roberts, Stuart Reges, and others.
More informationlecture24: Disjoint Sets
lecture24: Largely based on slides by Cinda Heeren CS 225 UIUC 22nd July, 2013 Announcements mp6 due tonight mp7 out soon! mt3 tomorrow night (7/23) Optional review instead of lab tomorrow Code Challenge
More informationCoding Standards for Java
Why have coding standards? Coding Standards for Java Version 1.3 It is a known fact that 80% of the lifetime cost of a piece of software goes to maintenance; therefore, it makes sense for all programs
More informationCOE428 Lecture Notes Week 1 (Week of January 9, 2017)
COE428 Lecture Notes: Week 1 1 of 10 COE428 Lecture Notes Week 1 (Week of January 9, 2017) Table of Contents COE428 Lecture Notes Week 1 (Week of January 9, 2017)...1 Announcements...1 Topics...1 Informal
More informationCMSC 150 LECTURE 7 RECURSION
CMSC 150 INTRODUCTION TO COMPUTING ACKNOWLEDGEMENT: THESE SLIDES ARE ADAPTED FROM SLIDES PROVIDED WITH INTRODUCTION TO PROGRAMMING IN JAVA: AN INTERDISCIPLINARY APPROACH, SEDGEWICK AND WAYNE (PEARSON ADDISON-WESLEY
More informationQueues and Unit Testing
Queues and Unit Testing Shreya Shankar Stanford CS 106B 3 July 2018 Based on slides created by Ashley Taylor, Marty Stepp, Chris Gregg, Keith Schwarz, Julie Zelenski, Jerry Cain, Eric Roberts, Mehran Sahami,
More informationCS 310 Advanced Data Structures and Algorithms
CS 310 Advanced Data Structures and Algorithms Recursion June 27, 2017 Tong Wang UMass Boston CS 310 June 27, 2017 1 / 20 Recursion Recursion means defining something, such as a function, in terms of itself
More informationTypes of recursion. Readings: none. In this module: a glimpse of non-structural recursion. CS 135 Winter : Types of recursion 1
Types of recursion Readings: none. In this module: a glimpse of non-structural recursion CS 135 Winter 2018 07: Types of recursion 1 Structural vs. general recursion All of the recursion we have done to
More informationCSCI-1200 Data Structures Spring 2017 Lecture 5 Pointers, Arrays, Pointer Arithmetic
CSCI-1200 Data Structures Spring 2017 Lecture 5 Pointers, Arrays, Pointer Arithmetic Announcements Submitty iclicker registration is still open. Even if you already registered on the iclicker website,
More informationNames and Functions. Chapter 2
Chapter 2 Names and Functions So far we have built only tiny toy programs. To build bigger ones, we need to be able to name things so as to refer to them later. We also need to write expressions whose
More informationUNIT 2B An Introduction to Programming. Announcements
UNIT 2B An Introduction to Programming 1 Announcements Tutoring help on Mondays 8:30 11:00 pm in the Mudge Reading Room Extra help session Fridays 12:00 2:00 pm in GHC 4122 Academic integrity forms Always
More informationAn Interesting Article. How Revolutionary Tools Cracked a 1700s Code.
Manipulating Text An Interesting Article How Revolutionary Tools Cracked a 1700s Code http://www.nytimes.com/2011/10/25/science/25code.html Announcements Breakout! due this Friday at 3:15PM. Stop by the
More informationEnumerated Types. CSE 114, Computer Science 1 Stony Brook University
Enumerated Types CSE 114, Computer Science 1 Stony Brook University http://www.cs.stonybrook.edu/~cse114 1 Enumerated Types An enumerated type defines a list of enumerated values Each value is an identifier
More informationisinstance and While Loops
CS 1110: Introduction to Computing Using Python Lecture 20 isinstance and While Loops [Andersen, Gries, Lee, Marschner, Van Loan, White] Announcements A4: Due 4/20 at 11:59pm Should only use our str method
More informationNote: This is a miniassignment and the grading is automated. If you do not submit it correctly, you will receive at most half credit.
Com S 227 Fall 2017 Miniassignment 1 50 points Due Date: Monday, October 16, 11:59 pm (midnight) Late deadline (25% penalty): Tuesday, October 17, 11:59 pm General information This assignment is to be
More informationImplementing Hash and AVL
Implementing Hash and AVL Data Structures and Algorithms CSE 373 SP 18 - KASEY CHAMPION 1 Warm Up CSE 373 SP 18 - KASEY CHAMPION 2 Announcements 1. Go look at your HW 1 scores, seems a lot are missing
More informationArrays and while Loops. Lecture 15 - COMP110 - Spring 2018
Arrays and while Loops Lecture 15 - COMP110 - Spring 2018 Announcements PS04 - March Sadness - Due Sunday 3/25 at 11:59pm Review Session - Tomorrow at 5pm in SN014 Tutoring Friday from 12pm - 4pm in SN115
More informationNotes slides from before lecture. CSE 21, Winter 2017, Section A00. Lecture 9 Notes. Class URL:
Notes slides from before lecture CSE 21, Winter 2017, Section A00 Lecture 9 Notes Class URL: http://vlsicad.ucsd.edu/courses/cse21-w17/ Notes slides from before lecture Notes February 8 (1) HW4 is due
More informationCS 106A, Lecture 16 Arrays
CS 106A, Lecture 16 Arrays suggested reading: Java Ch. 11.1-11.5 This document is copyright (C) Stanford Computer Science and Marty Stepp, licensed under Creative Commons Attribution 2.5 License. All rights
More informationAssignment #1: /Survey and Karel the Robot Karel problems due: 1:30pm on Friday, October 7th
Mehran Sahami Handout #7 CS 06A September 8, 06 Assignment #: Email/Survey and Karel the Robot Karel problems due: :0pm on Friday, October 7th Email and online survey due: :9pm on Sunday, October 9th Part
More informationCS/COE 1501 cs.pitt.edu/~bill/1501/ More Math
CS/COE 1501 cs.pitt.edu/~bill/1501/ More Math Exponentiation x y Can easily compute with a simple algorithm: Runtime? ans = 1 i = y while i > 0: ans = ans * x i-- 2 Just like with multiplication, let s
More informationCarleton University Department of Systems and Computer Engineering SYSC Foundations of Imperative Programming - Winter Lab 8 - Structures
Carleton University Department of Systems and Computer Engineering SYSC 2006 - Foundations of Imperative Programming - Winter 2012 Lab 8 - Structures Objective To write functions that manipulate structures.
More informationYEAH 2: Simple Java! Avery Wang Jared Bitz 7/6/2018
YEAH 2: Simple Java! Avery Wang Jared Bitz 7/6/2018 What are YEAH Hours? Your Early Assignment Help Only for some assignments Review + Tips for an assignment Lectures are recorded, slides are posted on
More informationChapter 15: Recursion
Chapter 15: Recursion Starting Out with Java: From Control Structures through Objects Fifth Edition by Tony Gaddis Chapter Topics Chapter 15 discusses the following main topics: Introduction to Recursion
More informationWhat is recursion? Recursion. How can a function call itself? Recursive message() modified. Week 10. contains a reference to itself.
Recursion What is recursion? Week 10 Generally, when something contains a reference to itself Gaddis:19.1-19.5 CS 5301 Spring 2014 Jill Seaman 1 Math: defining a function in terms of itself Computer science:
More informationCS 134 Programming Exercise 9:
CS 134 Programming Exercise 9: Nibbles Objective: To gain experience working with 2 dimensional arrays. The Problem Nibbles is a snake. Nibbles moves around a field, looking for food. Unfortunately, Nibbles
More informationPractice Midterm Exam #1
Eric Roberts Handout #23 CS106B January 28, 2013 Practice Midterm Exam #1 Review session: Sunday, February 3, 7:00 9:00 P.M., Hewlett 201 (next door) Midterm #1: Tuesday, February 5, 3:15 5:15 P.M., Braun
More informationRECURSION (CONTINUED)
RECURSION (CONTINUED) Lecture 9 CS2110 Spring 2018 Prelim two weeks from today: 13 March. 1. Visit Exams page of course website, check what time your prelim is, complete assignment P1Conflict ONLY if necessary.
More information