Class 5: Classes and Objects
Class
1.00/1.001 - Introduction to
Computation and Problem Solving
Fall 2005
Objects
Objects are things
Recall the description of libraries, books,
paperback books from Session 1
We decompose programming problems
into a

1.00 Lecture 22
November 1, 2005
Systems of Linear Equations
Systems of Linear Equations
3x0 + x1 - 2x2 = 5
2x0 + 4x1 + 3x2 = 35
x0 - 3x1
= -5
3 1 -2
x0
5
2 4 3
x1
= 35
1 -3 0
x2
-5
A
x = b
3 x 3 3 x 1 3 x 1
1
Algorithm to Solve Linear System
x0
x

1.00 Lecture 20
October 27, 2005
More on root finding
Numerical Integration
Newtons Method
Based on Taylor series expansion:
f ( x + ) f ( x) + f ' ( x) + f ' ' ( x) 2 / 2 + .
For small increment and smooth function,
higher order derivatives are small a

1.00 - Lecture 37 December 13, 2005
Java and the Web
Internet and TCP/IP
Internet is "just" a set of loosely interconnected networks
A set of local area networks connected via wide area networks Network segments interconnect via routers:
Dedicated comp

Introduction to Computation and Problem Solving
Class 17: Class Lab: The Graphics 2D API
Prof. Steven R. Lerman and Dr. V. Judson Harward
1
The Origins of the Java Graphics 2D API
The original Java GUI toolkit, the AWT, was a quick and dirty solution. It

Introduction to Computation and Problem
Solving
Class 23: Introduction to Data
Class
Structures: Stacks and Queues
Prof. Steven R. Lerman
and
Dr. V. Judson Harward
1
Algorithms, Data Structures, and
Patterns
An algorithm is a precise but not necessarily f

Introduction to Computation and Problem
Solving
Class 24: Case Study:
Class
Building a Simple Postfix Calculator
Prof. Steven R. Lerman
and
Dr. V. Judson Harward
1
Goals
To build a calculator to show how to
divide functionality up into
meaningful classes

Introduction to Computation and Problem
Solving
Class 26:
Class
Linked Lists
Prof. Steven R. Lerman
and
Dr. V. Judson Harward
The Java Collection Classes
The java.util package contains
implementations of many data structures that we
are also going to dis

Introduction to Computation and Problem
Solving
Class 29:
Class
Introduction to Streams
November 22, 2005
Prof. Steven R. Lerman
and
Dr. V. Judson Harward
Goals
Just as Java has a modern approach to error handling
inherited from C+, Java communicates with

Introduction to Computation and Problem Solving
Class 25: Error Handling in Java
Prof. Steven R. Lerman and Dr. V. Judson Harward
Goals
In this session we are going to explore better and worse ways to handle errors. In particular, we are going to learn ab

Introduction to Computation and Problem Solving
Class 28: Class Binary Search Trees
Prof. Steven R. Lerman and Dr. V. Judson Harward
Binary Search Trees
In the previous lecture, we defined the concept of binary search tree as a binary tree of nodes conta

Introduction to Computation and Problem
Solving
Class 27:
Class
Nested Classes and
an Introduction to Trees
Prof. Steven R. Lerman
and
Dr. V. Judson Harward
Goals
To explain in more detail the different
types of nested classes and how to use
them. A nest

Introduction to Computation and Problem Solving
Class 30:
Lab: Streams
November 29, 2005
Prof. Steven R. Lerman and Dr. V. Judson Harward
The Logger Application
2
1
Goals Using the framework of the Logger application, we are going to explore three ways

Introduction to Computation and Problem
Solving
Class 35:
Class
Active Learning: Using Threads
to Build an Animation
Prof. Steven R. Lerman
and
Dr. V. Judson Harward
Ticker Application
Our goal is to use a separate thread to drive an
animation that scrol

Introduction to Computation and Problem
Solving
Class 33: Sorting
December 6, 2005
December
Prof. Steven R. Lerman
and
Dr. V. Judson Harward
Why Is Sorting Interesting?
Sorting is an operation that occurs as part of
many larger programs.
There are man

Introduction to Computation and Problem Solving
Class 34: Class Introduction to Threads
Prof. Steven R. Lerman and Dr. V. Judson Harward
What is a Thread?
Imagine a Java program that is reading large files over the Internet from several different servers

Introduction to Computation and Problem
Solving
Class 31:
Class
Lab: Hashing
Prof. Steven R. Lerman
and
Dr. V. Judson Harward
Motivation
Can we search in better than O( lg n ) time?
The operation of a computer memory does
considerably better than this.

1.00 Lecture 19
October 24, 2005
Numerical Methods:
Root Finding
Remember Java Data Types
Type
byte
short
int
long
float
double
char
boolean
Size
(bits)
8
16
32
64
32
64
16
1
Range
-128 to 127
-32,768 to 32,767
-2,147,483,648 to 2,147,483,647
-9,223,372,0

1.00 Lecture 21
October 28, 2005
Matrices
Matrices
Matrix is 2-D array of m rows by n columns
a00
a01
a02
a03
a0n
a10
a11
a12
a13
a1n
a20
a21
a22
a23
a02n
am0
am1
am2
am3
amn
In math notation, we use index 1, m and 1, n.
In Java, we usually use

1.00/1.001 - Session 2
Fall 2005
Basic Java Data Types,
Control Structures
Java Data Types
8 primitive or built-in data types
4 integer types (byte, short, int, long)
2 floating point types (float, double)
Boolean (boolean)
Character (char)
These ar

Lecture 4 1.00 Fall 2005
More on Java Data Types and Control Structures
Control Structures: Branch
General form
if (boolean) statement;
if (x = y)
a = 20; if (x =z) cfw_ b = 10; c = 20; if ( x = y ) cfw_
a = 10; b = 20;
else x = y; if ( x > 60)
y =

Class 1: Introduction
Introduction to Computation and Problem Solving
Prof. Steven R. Lerman Prof. and Dr. V. Judson Harward
Handouts for Today Handouts
Course syllabus Academic Honesty Guidelines Laptop request form How to install Java and Eclips

Class 6: Lab Session on
Class
Classes and Objects
1.00/1.001 - Introduction to
Computation and Problem Solving
Using Methods
Methods are invoked using the dot (.) operator
Method always ends with parentheses
BigInteger a= new BigInteger(1000000000000);

1.00 - Introduction to Computation and
Problem Solving
Class 9:
Static Methods and Data Members
Prof. Steven R. Lerman
and
Dr. V. Judson Harward
Announcements/Reminders
The first quiz will be during class, 11:00 on
Friday, October 7. The quiz is open
bo

Session 7
Methods Strings Constructors this Inheritance
Java Methods
Methods are the interface or communications between classes
They provide a way to invoke the same operation from many places in your program, avoiding code repetition They hide imp

Class 10: Recursion
Introduction to Computation
Introduction
and Problem Solving
Prof. Steven R. Lerman
and
Dr. V. Judson Harward
Methods and Variables, 1
public class Variables
cfw_
public static void main(String[] args)
cfw_
int i = 42;
i = incr( i );
S

Class 11: Scope and Access
Introduction to Computation
and Problem Solving
Prof. Steven R. Lerman
Prof.
and
Dr. V. Judson Harward
Variable Lifecycles
Instance (or object) variables
Created when their containing object is created
Initialized to defau

1.00/1.001 - Lecture 8
Arrays and ArrayLists
Arrays-1
Arrays are a simple data structure
Arrays store a set of values of the same type
Built-in types (int, double, etc.) or
Objects (Students, Dates, etc.)
Arrays are part of the Java language
Arrays

Class 3: The Eclipse IDE
Introduction to Computation
Introduction
and Problem Solving
Prof. Steven R. Lerman
and
Dr. V. Judson Harward
What is an IDE?
An integrated development environment (IDE) is
an environment in which the user performs the
core devel

Class 13: Inheritance and Interfaces
Introduction to Computation
Introduction
and Problem Solving
Prof. Steven R. Lerman
and
Dr. V. Judson Harward
More on Abstract Classes
Classes can be very general at the top of a
class hierarchy.
For example, MIT cou