Preface xv
→ 1 Computer Basics 1
What Is a Computer? 1
Hardware 3
Central Processing Unit (CPU) 4
Memory 6
Input/Output devices (I/O) 7
Software 9
Operating Systems 9
Internet and the Web 11
Web Browsers and Servers 13
Web Addresses 13
Accessing Local Pages 14
Looking Ahead... 15
Chapter Summary 16
Review Questions 16
References 18
↓ 2 HTML and Web Pages 19
HTML Basics 20
HTML Tags 20
HTML Elements 20
Document Formatting 21
Text Spacing 22
Headings and Alignment 23
Font Formatting 25
Hypertext and Multimedia 26
Hyperlinks 27
Images 28
Lists 30
Formatting Lists 30
Tables 31
Table Borders 32
Aligning Images and Text 34
Making Pages Accessible 35
Looking Ahead... 37
Chapter Summary 37
Supplemental Material and Exercises 38
→ 3 The Internet and the Web 41
History of the Internet 42
ARPANet 42
Growth and Privatization 43
How the Internet Works 45
Distributed Network 45
Packet Switching 47
Internet Protocols: TCP/IP 48
Domain Names 48
History of the Web 50
Hypertext and the Web 50
Mainstream Adoption of the Web 51
Web Growth 52
How the Web Works 53
HTML 53
Web Protocol: HTTP 53
Caching 54
Looking Ahead... 54
Chapter Summary 55
Review Questions 56
References 57
Endnotes 57
↓ 4 JavaScript and Dynamic Web Pages
58
Dynamic Web Pages 59
Interaction via Assignments and Write Statements
59
Formatting Output 61
JavaScript Variables 63
Variables and Memory Cells 63
Interactive Pages 67
Localizing Changes with Variables 70
Example: Interactive Stories 70
Looking Ahead... 72
Chapter Summary 72
Supplemental Material and Exercises 73
↓ 5 JavaScript Numbers and Expressions
78
Data Types and Operators 78
Variables and Expressions 80
Number Representation 81
Evaluating Mixed Expressions 82
Prompting for Numbers 83
Predefined JavaScript Functions 87
Raising Numbers to a Power 89
Generating Random Numbers 90
Programming Errors and Debugging 91
Looking Ahead... 92
Chapter Summary 92
Supplemental Material and Exercises 93
→ 6 The History of Computers 98
Generation 0: Mechanical Computers (1642-1945) 99
Programmable Devices 100
Electromagnetic Relays 102
Generation 1: Vacuum Tubes (1945-1954) 103
Computing and World War II 104
The von Neumann Architecture 106
Generation 2: Transistors (1954-1963) 107
High-Level Programming Languages 108
Generation 3: Integrated Circuits (1963-1973) 108
Large Scale Integration 109
Computing for Businesses 109
Generation 4: VLSI (1973-1985) 110
The Personal Computer Revolution 110
Object-Oriented Programming 112
Generation 5: Parallel Processing & Networking 1985-????) 112
Looking Ahead... 113
Chapter Summary 113
Review Questions 114
Endnotes 116
References 116
↓ 7 Abstraction and User-Defined Functions
117
User-Defined Functions 118
The Structure of Functions 119
Multiple Functions in a Page 120
Functions with No Return Statement 121
Multiple Inputs 122
Parameters and Local Variables 124
Declaring Local Variables 124
The random.js Library 127
Looking Ahead... 129
Chapter Summary 130
Supplemental Material and Exercises 131
→ 8 Algorithms and Programming Languages
136
Algorithms 137
Algorithms in the Real World 137
Designing and Analyzing Algorithms 137
An Alternative Algorithm 140
Algorithm Analysis 140
Big-Oh Notation 142
Algorithm Example: Searching a List 142
Sequential Search 142
Binary Search 143
Algorithm Analysis 144
Algorithm Example: Approximating a Square Root 144
Algorithm Analysis 145
Algorithms and Programming 146
Machine Languages 146
High-Level Languages 147
Program Translation 148
Interpreters and Compilers 150
Looking Ahead... 151
Chapter Summary 151
Review Questions 152
References 154
↓ 9 Event-Driven Programming
155
Initiating Actions via Buttons 156
Buttons and Forms 156
Input/Output via Text Boxes 157
Text Boxes for Displaying Output 158
Text Boxes for Accessing Input 161
Text Boxes for Handling Both Input and Output 164
Input/Output via Text Areas 164
Dynamic Images 167
Looking Ahead... 168
Chapter Summary 169
Supplemental Material and Exercises 170
|
→ 10 Computer Science as a Discipline
176
Computer "Science" 177
Artificial Science 178
Computer Science Themes 178
Hardware 179
Software 179
Theory 180
Subfields of Computer Science 181
Algorithms and Data Structures 181
Architecture 184
Operating Systems and Networks 185
Software Engineering 187
Artificial Intelligence and Robotics 188
The Ethics of Computing 189
Looking Ahead... 191
Chapter Summary 191
Review Questions 192
Endnotes 193
References 193
↓ 11 Conditional Execution 195
If Statements 196
Boolean Tests 196
Nested If Statements 200
Cascading If-Else Statements 201
Example: Counting Dice Rolls 202
Counters 205
Boolean Expressions 206
Looking Ahead... 208
Chapter Summary 209
Supplemental Material and Exercises 210
→ 12 Data Representation 214
Analog vs. Digital 214
Binary Numbers 216
Representing Integers 217
Representing Real Numbers 218
Representing Characters and Strings 220
Representing Other Types of Data 221
Sounds 222
Images 223
How Computers Distinguish among Data Types 225
Looking Ahead... 225
Chapter Summary 226
Review Questions 227
References 228
↓ 13 Conditional Repetition
229
While Loops 230
Counter-Driven Loops 236
Variables and Repetition 237
Example: Generating Hailstone Sequences 243
Looking Ahead... 244
Chapter Summary 244
Supplemental Material and Exercises 245
→ 14 Inside the Computer - The von Neumann
Architecture
250
CPU Subunits and Datapath 250
CPU Subunits 251
CPU Datapath Cycles 251
Datapath Simulator 252
CPU and Main Memory 254
Transferring Data to and from Main Memory 254
Datapath with Memory Simulator 255
Stored-Program Computer 257
Machine Languages 257
Control Unit 259
Stored-Program Computer Simulator 260
The Role of Input/Output Devices 264
Machine vs. Assembly Languages 265
Looking Ahead... 266
Chapter Summary 267
Review Questions 268
References 269
↓ 15 JavaScript Strings 270
Strings as Objects 270
Properties and Methods 271
Common String Manipulation Methods 274
String Concatenation 274
Searching Strings 276
General Searches 276
String Manipulations and Repetition 278
Example: Recognizing Palindromes 280
Looking Ahead... 280
Chapter Summary 281
Supplemental Material and Exercises 281
→ 16 Inside the Computer - Transistors and
Integrated
Circuits
286
Electricity and Switches 287
Electricity Basics 287
Switches 287
Transistors 288
Transistors as Switches 289
From Transistors to Gates 290
Gates and Binary Logic 291
From Gates to Complex Circuits 292
Example: Designing Memory Circuitry 296
From Circuits to Microchips 297
The Integrated Circuit 297
Manufacturing Integrated Circuits 298
Packaging Microchips 299
Looking Ahead... 300
Chapter Summary 301
Review Questions 302
References 303
↓ 17 JavaScript Arrays 304
Arrays as Objects 305
Accessing Items in an Array 305
Assigning Items in an Array 306
From Strings to Arrays 307
The split Method for Strings 308
Example: Generating Acronyms 309
Arrays of Numbers 311
Example: Maintaining Dice Statistics Using an Array 315
Approach 1: Separate Counters 315
Approach 2: An Array of Counters 317
Looking Ahead... 318
Chapter Summary 319
Supplemental Material and Exercises 320
→ 18 Computers and Society 327
Positive Impact of Technology 327
Computers and Programs for Everyday Tasks 328
The Internet and Web as Information Sources 330
The Internet and Web as Communications Media 331
The Internet and Web for Commerce 333
Potential Dangers of Technology 335
Reliance on Complex Systems 336
Information Overload 336
Privacy and Security 337
The Digital Divide 339
Looking Beyond... 340
Chapter Summary 340
Review Questions 341
Endnotes 342
References 342
Appendix A: Browser Basics 343
Appendix B: Common Text Editors 350
Appendix C: HTML Reference 355
Appendix D: JavaScript Reference 359
Appendix E: random.js Library 366
Index 367
Photo Credits 372
|