Preface xv
→ 1 Computer Basics 1
What Is a Computer? 1
Hardware 3
Central Processing Unit (CPU) 3
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 15
Review Questions 16
References 17
↓ 2 HTML and Web Pages 18
HTML Basics 19
HTML Tags 19
HTML Elements 20
Document Formatting 20
Text Spacing 21
Headings and Alignment 22
Font Formatting 24
Hypertext and Multimedia 25
Hyperlinks 26
Images 27
Lists 28
Formatting Lists 29
Tables 31
Table Borders 31
Aligning Images and Text 32
Making Pages Accessible 34
Looking Ahead... 35
Chapter Summary 35
Supplemental Material and Exercises 36
→ 3 The Internet and the Web 40
History of the Internet 41
ARPANet 41
Growth and Privatization 42
How the Internet Works 45
Distributed Network 45
Packet Switching 46
Internet Protocols: TCP/IP 47
Domain Names 47
History of the Web 49
Hypertext and the Web 49
Mainstream Adoption of the Web 50
Web Growth 51
How the Web Works 52
HTML 52
Web Protocol: HTTP 52
Caching 53
Looking Ahead... 53
Chapter Summary 54
Review Questions 55
References 56
Endnotes 56
↓ 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 69
Example: Interactive Stories 71
Looking Ahead... 71
Chapter Summary 72
Supplemental Material and Exercises 72
↓ 5 JavaScript Numbers and Expressions
77
Data Types and Operators 77
Variables and Expressions 79
Number Representation 80
Evaluating Mixed Expressions 81
Prompting for Numbers 82
Predefined JavaScript Functions 86
Raising Numbers to a Power 88
Generating Random Numbers 89
Programming Errors and Debugging 89
Looking Ahead... 90
Chapter Summary 91
Supplemental Material and Exercises 91
→ 6 The History of Computers 96
Generation 0: Mechanical Computers (1642-1945) 97
Programmable Devices 98
Electromagnetic Relays 100
Generation 1: Vacuum Tubes (1945-1954) 101
Computing and World War II 102
The von Neumann Architecture 104
Generation 2: Transistors (1954-1963) 105
High-Level Programming Languages 106
Generation 3: Integrated Circuits (1963-1973) 106
Large Scale Integration 107
Computing for Businesses 107
Generation 4: VLSI (1973-1985) 108
The Personal Computer Revolution 108
Object-Oriented Programming 110
Generation 5: Parallel Processing & Networking 1985-????) 111
Looking Ahead... 111
Chapter Summary 112
Review Questions 113
Endnotes 114
References 114
↓ 7 Event-Driven Pages
115
Initiating Actions via Buttons 116
Input/Output via Text Boxes 117
Text Boxes for Displaying Output 118
Text Boxes for Accessing Input 120
Text Boxes for Handling Both Input and Output 123
Input/Output via Text Areas 123
Dynamic Images 125
Simplifying Buttons with Functions 127
Looking Ahead... 129
Chapter Summary 130
Supplemental Material and Exercises 131
→ 8 Algorithms and Programming Languages
137
Algorithms 138
Algorithms in the Real World 138
Designing and Analyzing Algorithms 139
An Alternative Algorithm 141
Algorithm Analysis 142
Big-Oh Notation 143
Algorithm Example: Searching a List 143
Sequential Search 143
Binary Search 144
Algorithm Analysis 145
Algorithm Example: Approximating a Square Root 145
Algorithm Analysis 147
Algorithms and Programming 147
Machine Languages 147
High-Level Languages 148
Program Translation 149
Interpreters and Compilers 151
Looking Ahead... 152
Chapter Summary 152
Review Questions 153
References 154
↓ 9 Abstraction and User-Defined Functions
156
The Structure of Functions 157
Functions with Inputs 158
Multiple Inputs 159
Parameters and Local Variables 161
Functions that Return Values 162
The random.js Library 166
Looking Ahead... 170
Chapter Summary 171
Supplemental Material and Exercises 171
|
→ 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 183
Operating Systems and Networks 185
Software Engineering 186
Artificial Intelligence and Robotics 188
Bioinformatics 189
The Ethics of Computing 191
Looking Ahead... 192
Chapter Summary 192
Review Questions 193
Endnotes 195
References 195
↓ 11 Conditional Execution 196
If Statements 197
Boolean Tests 197
Nested If Statements 200
Cascading If-Else Statements 202
Example: Counting Dice Rolls 203
Counters 206
Boolean Expressions 207
Looking Ahead... 209
Chapter Summary 210
Supplemental Material and Exercises 211
→ 12 Data Representation 215
Analog vs. Digital 215
Binary Numbers 217
Representing Integers 218
Representing Real Numbers 219
Representing Characters and Strings 221
Representing Other Types of Data 222
Sounds 222
Images 224
How Computers Distinguish among Data Types 226
Looking Ahead... 226
Chapter Summary 227
Review Questions 228
References 229
↓ 13 Conditional Repetition
230
While Loops 231
Counter-Driven Loops 237
Variables and Repetition 238
Example: Generating Hailstone Sequences 244
Looking Ahead... 245
Chapter Summary 245
Supplemental Material and Exercises 246
→ 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... 267
Chapter Summary 268
Review Questions 268
References 269
↓ 15 JavaScript Strings 271
Strings as Objects 271
Properties and Methods 272
Common String Manipulation Methods 275
String Concatenation 275
Searching Strings 277
General Searches 277
String Manipulations and Repetition 279
Example: Recognizing Palindromes 281
Looking Ahead... 281
Chapter Summary 281
Supplemental Material and Exercises 282
→ 16 Inside the Computer - Transistors and
Integrated
Circuits
287
Electricity and Switches 288
Electricity Basics 288
Switches 288
Transistors 289
Transistors as Switches 290
From Transistors to Gates 291
Gates and Binary Logic 292
From Gates to Complex Circuits 294
Example: Designing Memory Circuitry 296
From Circuits to Microchips 297
The Integrated Circuit 297
Manufacturing Integrated Circuits 298
Packaging Microchips 299
Looking Ahead... 301
Chapter Summary 301
Review Questions 302
References 304
↓ 17 JavaScript Arrays 305
Arrays as Objects 306
Accessing Items in an Array 306
Assigning Items in an Array 307
From Strings to Arrays 308
The split Method for Strings 309
Example: Generating Acronyms 310
Arrays of Numbers 312
Example: Maintaining Dice Statistics Using an Array 316
Approach 1: Separate Counters 316
Approach 2: An Array of Counters 316
Looking Ahead... 319
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 332
The Internet and Web for Commerce 333
Potential Dangers of Technology 335
Reliance on Complex Systems 335
Information Overload 336
Privacy and Security 336
The Digital Divide 338
Looking Beyond... 339
Chapter Summary 339
Review Questions 340
Endnotes 341
References 342
Appendix A: Browser Basics 343
Appendix B: Common Text Editors 349
Appendix C: HTML Reference 354
Appendix D: JavaScript Reference 357
Appendix E: random.js Library 364
Index 365
Photo Credits 381
|