Professional Documents
Culture Documents
Class 2: CS 101 Chapter 1: Introduction Aaron Bloomfield Spring 2007
Class 2: CS 101 Chapter 1: Introduction Aaron Bloomfield Spring 2007
Class 2
CS 101
Chapter 1: Introduction
Aaron Bloomfield
Spring 2007
Lets begin
Goal
What is a computer?
So what is a computation?
Definition of computing:
Duh!
Axiom
Stonehenge
Computer Size
ENIAC then
ENIAC today
Algorithms
10
11
Algorithms
What is an algorithm?
A step-by-step problem-solving procedure,
especially an established, recursive computational
procedure for solving a problem in a finite number
of steps
13
14
15
An optical illusion
16
Algorithm correctness
17
Incorrect algorithms
Can
Can
Can
Can
be wrong
be inefficient
never stop
have other problems as well
18
From http://en.for-ua.com/blog/2005/12/09/102028.html
19
20
22
23
It never halts
Note that humans know to not to spend forever performing the
algorithm
But computers do not!
25
Given an integer n
Keep track of an ongoing sum (starts at 0)
Repeat
Until n is zero
Our goal
27
Correct algorithms
Is this blue?
Definitely
Is this blue?
Definitely not
28
30
Carved watermelons
31
Programming a computer
32
33
ENIAC (1945)
Binary
100100010101001010101010
Assembly
FORTRAN (1954)
34
Programming Languages
BASIC
COBOL
Pascal
C (1972) by Dennis Ritchie
C++ (1985) by Bjarne Stroustrup
Java (1991) by James Gosling and others at Sun
Microsystems
35
Background
36
A bit is either a 1 or a 0
A byte is 8 bits:
01001010
As there are 8 bits per byte, each byte can hold 28=256 values
01001010 = 74
37
= Kibi (Ki)
= Mebi (Mi)
= Gibi (Gi)
= Tebi (Ti)
38
A music file on a CD
A movie clip
A marketing trick
= 250.06 Gigabytes
= 232.89 Gibibytes
Todays demotivators
41
Chapter 1
Class 3
Programming Task
44
HelloWorld.java
// Purpose: say hello!
public class HelloWorld {
public static void main(String[] args) {
System.out.println (Hello, world!");
}
}
Sample output
46
Program parts
47
Key words
Operators
Punctuation
Programmer-defined identifiers
Strict syntactic rules
48
Java Documentation
49
Key Words
public
class
static
void
String
Key words
Programming Languages
51
Lines vs Statements
52
Good commenting
Bad commenting
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
While at NCR, he was convicted for illegal anticompetitive sales practices (e.g. he used to have
people sell deliberately faulty cash registers, either
second-hand NCR or from competitors; soon after the
second-hand NCR or competitors cash register failed,
an NCR salesperson would arrive to sell them a brand
new NCR cash register). He was sentenced, along with
John H. Patterson (the owner of NCR), to one year of
imprisonment. Their conviction was unpopular with the
public, due to the efforts of Patterson and Watson to
help those affected by the 1913 Dayton, Ohio floods,
but efforts to have them pardoned by President Woodrow
Wilson were unsuccessful. However, the Court of
Appeals overturned the conviction on appeal in 1915,
on the grounds that important defense evidence should
have been admitted.
54
/*
* If the new process paused because it was
* swapped out, set the stack level to the last call
* to savu(u_ssav). This means that the return
* which is executed immediately after the call to aretu
* actually returns from the last routine which did
* the savu.
*
* You are not expected to understand this.
*/
if(rp->p_flag&SSWAP) {
rp->p_flag =& ~SSWAP;
aretu(u.u_ssav);
}
Source: http://www.tuhs.org/Archive/PDP-11/Trees/V6/usr/sys/ken/slp.c
55
Human stupidity
56
Chapter 1
Extra Material
59
60
Software Engineering
in
the
designing,
writing,
testing,
debugging,
documenting,
modifying, and
maintaining.
61
Software Engineering
program specifications,
diagrams of screen output,
diagrams representing the program components and the
flow of data,
pseudocode,
examples of expected input and desired output.
62
Procedural programming
Object oriented programming
Data hiding
Code reusability
63
Computer Systems
64
Computer Systems
Hardware
Software
Operating systems
Application software
65
Input Devices
ALU
Control Unit
RAM
Output Devices
Input / Output
Devices
66
67
Instruction (input)
Arithmetic
Logic
Unit
Result (output)
Control
Unit
68
Fetch
Execute
Decode
69
contains:
is volatile
Secondary Storage
non-volatile
long-term memory
Examples
Hard drive
CD RW drive
DVD RAM drive
Compact Flash card
71
Input Devices
Keyboard
Mouse
Scanner
Digital camera
72
Output Devices
devices
Monitors
Printers
Operating Systems
Application Software
74
Operating Systems
DOS
Windows
Unix
Apple
75
Operating Systems
single user
DOS
Windows 95/98/ME
multi-user
Unix
BSD
Windows NT/2000/XP
OS/X
76
Application Software
Spreadsheets
Word processors
Accounting software
Tax software
Games
77