theortical concepts of computer science and computation
CSCI 610

Spring 2014
11 February 2008
CSCI610: Infinite Sets and Computable Functions
Infinite Sets
We will address some important issues in connection with the computation of functions  having to do with
the limits of what can be computed  but first we must understand some
theortical concepts of computer science and computation
CSCI 610

Fall 2015
5640_ch05.fm Page 235 Wednesday, February 11, 2004 2:17 PM
CHAPTER
5
Defining Classes II
5.1 STATIC METHODS AND STATIC VARIABLES 237
Static Methods 237
Pitfall: Invoking a Nonstatic Method Within a Static
Method 239
Static Variables 241
The Math Class 244
theortical concepts of computer science and computation
CSCI 610

Fall 2015
5640_ch10.fm Page 515 Wednesday, February 11, 2004 2:33 PM
CHAPTER
10
File I/O
10.1 INTRODUCTION TO FILE I/O 516
Streams 516
Text Files and Binary Files 517
10.2 TEXT FILES 518
Writing to a Text File 518
Pitfall: A try Block Is a Block 524
Pitfall: Overwr
theortical concepts of computer science and computation
CSCI 610

Fall 2015
5640_ch17.fm Page 863 Friday, February 13, 2004 4:54 PM
CHAPTER
17
Applets
17.1
A BRIEF INTRODUCTION TO HTML 864
HTML Formatting Commands 865
Outline of an HTML Document 867
Tip: Comments 867
Hyperlinks 870
Inserting a Picture 873
Pitfall: Not Using Your
theortical concepts of computer science and computation
CSCI 610

Fall 2015
5640_ch18.fm Page 895 Friday, February 13, 2004 4:52 PM
CHAPTER
18
Swing II
18.1 WINDOW LISTENERS 896
Example: A Window Listener Inner Class 897
The dispose Method 902
Pitfall: Forgetting to Invoke
setDefaultCloseOperation 902
The WindowAdapter Class 903
theortical concepts of computer science and computation
CSCI 610

Fall 2015
5640_ch19.fm Page 957 Tuesday, February 10, 2004 4:11 PM
CHAPTER
19
Java Never Ends
19.1 MULTITHREADING 958
Example: A Nonresponsive GUI 959
Thread.sleep 959
The getGraphics Method 963
Fixing a Nonresponsive Program Using Threads 964
Example: A Multithrea
theortical concepts of computer science and computation
CSCI 610

Fall 2015
5640_ch16.fm Page 781 Friday, February 13, 2004 4:56 PM
CHAPTER
16
Swing I
16.1
EVENTDRIVEN PROGRAMMING 783
Events and Listeners 783
16.2
BUTTONS, EVENTS, AND OTHER SWING
BASICS 784
Example: A Simple Window 785
Pitfall: Forgetting to Program the CloseWi
theortical concepts of computer science and computation
CSCI 610

Fall 2015
Asteroids
You will be reinvigorating the 1979 arcade classic, a timeless tale of triumph and
sacrifice, of hatred and love, of space travel wrapped around our screens and our
hearts. One solitary ship, an interminable journey, a violent struggle for freed
theortical concepts of computer science and computation
CSCI 610

Fall 2015
PracticeProblems:ClassesandObjects(Chapters5and6)
1)TheJavaclasscalledH l d y
o i a isstartedbelow.AnobjectofclassH l d y
o i a representsa
holidayduringtheyear.Thisclasshasthreeinstancevariables:
n m ,whichisaS r n representingthenameoftheholiday
ae
tig
theortical concepts of computer science and computation
CSCI 610

Fall 2015
Practice Problems: Classes and Objects (Chapters 5 and 6)
1) The Java class called Holiday is started below. An object of class Holiday
represents a holiday during the year. This class has three instance variables:
name, which is a String representing th
theortical concepts of computer science and computation
CSCI 610

Fall 2015
5640_ch02.fm Page 57 Wednesday, February 11, 2004 2:12 PM
CHAPTER
2
Console Input and Output
2.1
SCREEN OUTPUT 58
System.out.println 58
Tip: Echo Input 81
A Preview of the StringTokenizer Class 83
Money Formats 61
Importing Packages and Classes 64
The Dec
theortical concepts of computer science and computation
CSCI 610

Fall 2015
5640_ch01.fm Page 1 Tuesday, February 10, 2004 3:54 PM
CHAPTER
1
Getting Started
1.1 INTRODUCTION TO JAVA 2
Origins of the Java Language 2
Objects and Methods 3
Applets 4
A Sample Java Application Program 5
ByteCode and the Java Virtual Machine 8
Class L
theortical concepts of computer science and computation
CSCI 610

Fall 2015
5640_apx4.fm Page 983 Tuesday, February 10, 2004 4:19 PM
Appendix 4
Summary of Classes and Interfaces
This appendix summarizes most of the library classes used in this book. This appendix includes
some methods, and even some classes, that are not discusse
theortical concepts of computer science and computation
CSCI 610

Spring 2014
Equivalence Relations and Partitions
So an equivalence relation on a set S partitions the elements of S into
equivalence sets: each element of S belongs to only one equivalence set and
the union of the sets is the original set S. (Think of the sitting at
theortical concepts of computer science and computation
CSCI 610

Spring 2014
Crossproduct, Relations, and Equivalence Relations
For two sets A and B, we define the crossproduct
AxB = cfw_(a,b)  a in A, b in B
That is, the crossproduct is a set of pairs, with the first element of each pair
a member of A, and the second element
theortical concepts of computer science and computation
CSCI 610

Spring 2014
CSCI 610
Assignment 4
NYIT
1. Express each of these statements using quantifiers. Then form the negation of the
statement so that no negation is to the left of a quantifier. Next, express the negation in
simple English.
b) There is a cat that can add.
c)E
theortical concepts of computer science and computation
CSCI 610

Spring 2014
Turing Machine:
Show the instructions and state diagram (as done in class) for an input
string over cfw_a b what moves it to the right one cell position.
start <0>
<0, a, , R, 1> start at state 0, read a, write nothing, move to the right, next state 1
<0,
theortical concepts of computer science and computation
CSCI 610

Spring 2014
Lecture 7  Homework
1. Using a conditional proof .
The team wins or I am sad. If the team wins, then I go to a movie. If I am sad then my dog barks. My
dog does not bark. Therefore, I go to a movie.
W : the team wins
S : I am sad
M : I go to a movie
B :
theortical concepts of computer science and computation
CSCI 610

Spring 2014
Homework Lecture 4
1. Here are some binary relations over A=cfw_0,1. Which of the properties hold?
a.
symmetric,transitive,irreflexive,antisymmetric
b. AA
reflexive, symmetric, transitive
c. eq = cfw_(0,0), (1,1)
reflexive, symmetric, transitive, antisym
theortical concepts of computer science and computation
CSCI 610

Spring 2014
Homework Lecture 3
1. Describe the set S defined inductively as follows:
Basis 2 S
Induction: x S implies x 3 S
S = cfw_2, 5, 8, 11, cfw_1, 4, 7, 10,
2. Using infix notion, find an inductive definition for
S = cfw_< >, < < > >, < < < > > >,
Basis:
theortical concepts of computer science and computation
CSCI 610

Spring 2014
From Lecture #2
1) SHOW the loop iterations in Euclid's algorithm to find gcd(117, 48)
117 = 48 * 2 + 21
48 = 21 * 2 + 6
21 = 6 * 3 + 3
6=3*2+0
Output = 3
2) It is 6 pm in New York, what time is it in Honolulu (5 hour difference). Use the mod
function to
theortical concepts of computer science and computation
CSCI 610

Spring 2014
Assignment #5
1. Example. Given a set of nine coins, one of which is bad, meaning that it is heavier or lighter than
the others. Find a good lower bound for a panbalance algorithm that finds the bad coin and
states whether it is heavy or light. Find an op
theortical concepts of computer science and computation
CSCI 610

Spring 2014
LECTURE #1:
ELEMENTARY NOTIONS AND NOTATION
1
Sandra Kopecky
Department of Computer Science
New York Institute of Technology
CSCI610
CSCI610
THEORETICAL CONCEPTS IN COMPUTERS
AND COMPUTATION
PROOF PRIMER
A Proof Primer
A proof is a demonstration that so
theortical concepts of computer science and computation
CSCI 610

Spring 2014
From lecture #1:
1) Using conditional proof, show that if x is even then x2 is even.
Assume x is even.
Then x=2k for some integer k. so,
we have x2 = (2k)2 = 4k2 =2(2k2)
which is an even integer since 2k2 is an integer QED
The contrapositive of the above
theortical concepts of computer science and computation
CSCI 610

Spring 2014
CSCI610
Chapter 6: Homework Problems
1. Show the truth table for the following propositional variables: P, Q, R and the following
connective: (r V p) ^ ( ( ~r V (p^q) ) ^ (r V q) )
P
Q
R
RVP
~R
P^Q
~R V (P ^ Q)
RVQ
(~R V (P ^ Q) ^
(R V Q)
T
T
T
T
F
F
F
F
theortical concepts of computer science and computation
CSCI 610

Spring 2014
Lecture 8  Homework
1. Draw the DFA for the following regular expression: a *bc* + ac
a
0
c
1
2
b
3
4
a
c
2. Given a grammar, what it the regular expression
a. S a  b
a+b
b. S aa  bb  ac
aa + bb + ac
c. S aB  c
B ^  bB
ab* + c
d. S ^  aaS  bbS
(aa