M

M/M/1 queues, 597600

MAC addresses, 877

Machine-language programming

arrays, 938941

benefits, 945

description, 907

functions, 931933

overview, 930

standard input, 936938

standard output, 934936

summary, 945946

TOY machine, 914

Magnitude

complex numbers, 402403

spatial vectors, 442443

Magritte, René, 363

main() methods, 45

multiple, 229

transfer of control, 193194

Majority function

adder circuits, 10281030

sum-of-products circuits, 1027

truth tables for, 1025

Mandelbrot, Benoît, 297, 406

Mandelbrot program, 406409

Maps, Mercator projections, 48

Markov, Andrey, 176

Markov chains

impact, 184

mixing, 179184

overview, 176

power method, 180181

squaring, 179180

Markov model paradigm, 460

Markov program, 180182

Markov systems, 802803

Markovian queues, 597

Marsaglia’s method, 85, 259

Masking bitwise operations, 892893

Matcher class for REs, 763

Matching graphs, 713

Math library, 192

accessing, 228

methods, 3032, 193, 198

Mathematical analysis, 498502

Mathematical functions, 202204

Mathematical induction, 262, 266

Mathematical models, 716

Matiyasevich, Yuri, 816

Matlab language, 1094

Matrices

boolean, 302

Hadamard, 122

images, 346347

matrix multiplication, 109

sparse, 666

transition, 172173

two-dimensional arrays, 106, 109110

vector multiplication, 110, 180

Mauchly, John, 924925

Maximum values in arrays, 209

Maximum keys in BSTs, 651

Maxwell–Boltzmann distributions, 257

McCarthy’s 91 function, 298

Mechanical systems, graphs for, 673

Memoization, 284

Memory

arrays, 91, 94, 515517

ArrayStackOfStrings, 569570

available, 520

bit-slice design, 10541056

circuits, 10541057

feedback loops as, 1048

flip-flops, 10491050

interfaces, 1054

leaks, 367, 581

linked lists, 571

memory bits, 1056

objects, 338, 514

performance, 513517

recursion, 282

references, 367

safe pointers, 366

strings, 515

TOY machine, 908909

two-dimensional arrays, 107

virtual, 972, 975976

Memory dumps, 909

Memory instructions

address instructions, 912

TOY machine, 913

Memory writes for CPU, 1079

Memoryless queues, 597

Mercator projections, 48

Merge program, 550552

Mergesort

divide-and-conquer, 554

overview, 550552

performance, 553

Metacharacters, 724, 730731

Method references, 470

Methods

abstract, 446

call chaining, 404

deprecated, 469

instance, 334, 385386

instance vs. static, 340

library, 2932

main(), 45

overriding, 452

static. See Functions; Static methods

stub, 303

variables within, 386388

MIDI Tuning Standard, 161

Midpoint displacement method, 278, 280

Milgram, Stanley, 670

Minimum keys in BSTs, 651

Minsky, Marvin, 780, 794

Minus signs (-)

compound assignments, 60

floating-point numbers, 2426

integers, 22

lambda expressions, 450

MIX machine, 947

Mixed-type operators, 2729

Mixing Markov chains, 176, 179184

MM1Queue program, 598600

Models

circuit. See Circuit models

computational, 716

mathematical, 716

universal, 794797

Modular programming, 191

classes in, 227229

code reuse, 226, 253

debugging, 253

encapsulation, 432

flow of control in, 227228

libraries in, 251254

machine language, 932

maintenance, 253

program size, 252253

Modules

abstraction layers, 1037

as classes, 228

CPU, 1076

description, 1034

interactions, 319

overview, 191

program counters, 1073

size, 319

summary, 254

Monochrome luminance, 343344

Monte Carlo simulation, 300, 307308

Moore’s Law

coping with, 971

description, 507508

Move-to-front strategy, 620

Movie–performer graph, 680

Multidimensional arrays, 111

Multiple arguments, 197

Multiple inheritance, 470

Multiple main() methods, 229

Multiple return statements, 198

Multiple I/O streams, 143

Multiplexers

bus switching, 1035

description, 1023

selection, 10191020

Multiplication

complex numbers, 402403

floating-point numbers, 2426

integers, 2223, 885

matrices, 109110

P search problems, 839

polar representation, 433

Multiway gates, 10151017, 1023

Music, 155159

Mutable types, 364, 439

N

N-body simulation

Body data type, 479480

file format, 483

force, 480482

overview, 478479

summary, 488

Universe data type, 483487

Names

arrays, 91

methods, 5, 30, 196

objects, 362

variables, 16

vertices, 675

NaN value, 26, 40

NAND function, 989991

Nash, John, 840

Natural numbers, 875

Natural recursion, 262

Negation axiom, 990

Negative numbers

array indexes, 116

representing, 38, 886888

Neighbor vertices, 671

Nested classes

iterators, 574

linked lists, 603605

Nesting conditionals and loops, 6264

new keyword

constructors, 385

Node objects, 609

String objects, 333

Newcomb, Simon, 224

Newline characters (\n)

compiler considerations, 10

escape sequences, 19

Newton, Isaac

dice question, 88

motion simulation, 478479

square root method, 65

Newton’s law of gravitation, 481

Newton’s method, 6567

Newton’s second law of motion, 480481

NFAs. See Nondeterministic finite-state automata (NFAs)

90–10 rule, 170, 176

Nodes

BSTs, 640642, 942

linked lists, 571573

new keyword, 609

Nondeterministic finite-state automata (NFAs)

DFA equivalence, 749750

Kleene’s theorem. See Kleene’s theorem

overview, 744

RE equivalence, 750751

recognition problem, 744745

trace example, 747

Nondominant inner loops, 510

NOR function, 989991

NOR gates

cross-coupled, 1050

description, 1014

Normal distribution functions

cumulative, 202203

probability density, 202203

NOT gates, 10131014

Not operation, 2627, 987989

NP-completeness

addressing problems, 852

boolean satisfiability, 853856

classifying problems, 851

Cook–Levin theorem, 844847

coping, 850857

Karp’s reductions, 845848

overview, 843844

proving, 844849

NP-hard problems, 858

NP search problems

difficult, 837

easy, 837

main question, 840841

nondeterminism, 835

overview, 833

solutions, 835

subset sum, 834

TSP problem, 862

vertex cover problem, 834, 842

0/1 ILP problem, 835

Null calls, 312

Null keys in symbol tables, 626

Null links in BSTs, 640

Null nodes in linked lists, 571572

null keyword, 415

Null transitions in NFAs, 744746

Null values in symbol tables, 626

NullPointerException, 370

Numbers

conversions, 21, 6769, 880881

intractability, 827

negative, 886888

real, 888890

Numerical integration, 449

Nyquist frequency, 161

O

Object class, 453455

Object-oriented programming

data types. See Data types

description, 254

overview, 329

Objects

arrays, 365

collections, 582583

comparing, 364, 545546

Complex, 404

equality, 454456

memory, 514

names, 362

orphaned, 366

references, 338339

String, 333334

type conversions, 339

uninitialized variables, 339

working with, 338339

Observations, 495496

Occam’s Razor, 814

Octal representation, 898

Odd parity function

adder circuits, 10281030

sum-of-products circuits, 1026

truth tables for, 1026

Off-by-one errors, 92

Offscreen canvas, 151

Offset binary representation, 889

On computable numbers, with an application to the Entscheidungsproblem article, 717

On/off switches, 1005

One-dimensional arrays, 90

One-hot OR gates, 1023

Onscreen canvas, 151

Opcodes, 911

Operands, 17

Operators and operations

boolean, 2627, 989991

comparisons, 2729, 364

compound assignments, 60

data types, 14, 331

description, 15

expressions, 17, 587

floating-point numbers, 24

integers, 22, 891

lambda, 450

overloading, 416

precedence, 17

reverse Polish notation, 590

stacks, 590

strings, 19, 21, 334, 453

TOY machine, 906

Optimal data compression, 814

Optimization

NP problems, 835

premature, 518

Optimizing compilers, 814

OR function, 987989

OR gates, 1014, 1023

Or operation

bitwise, 891892

boolean type, 2627

TOY machine, 913

Order in BSTs, 640, 642643

Order statistics, 651

Order-of-growth classifications

constant, 503

cubic, 505508

exponential, 505508

linear, 504505, 507508

linearithmic, 504505, 507508

logarithmic, 503

overview, 503

performance analysis, 500501

quadratic, 504505, 507508

Ordered operations

binary search trees, 651

symbol tables, 624

Orphaned objects, 366

Orphaned stack items, 581

Out library, 355356

Outer loops, 62

Outline shapes, 149

Output

arithmetic logic units, 1032

array libraries, 237238

circuit models, 10021004

clocks, 10591060

data types, 353

file concatenation, 356

gates, 1013

machine language, 934936

print statements, 8

printf() method, 126129

standard, 127, 129132

standard audio, 155159

standard drawing. See Standard drawing

stream data types, 355

two-dimensional arrays, 107

virtual machines, 969970

Overflow

arithmetic, 885

arrays, 95

attacks, 963

guarding against, 898

integers, 23

negative numbers, 38

Overhead for objects, 514

Overloading

operators, 416

static methods, 198

Overriding methods, 452

P

The P= NP Question and Gödel’s Lost Letter book, 856

P search problems, 837

examples, 839

main question, 840841

Padding object memory, 514

Page, Lawrence, 184

Page ranks, 176177

Palindromes

description, 719

Watson–Crick, 374

Paper size, 294

Paper tape, 934938

Papert, Seymour, 400

Parallel arrays, 411

Parallel edges, 676

Parameter variables

lambda expressions, 450

static methods, 196197, 207

Parameterized data types, 582586

Parameters

in performance, 511

TOY-8 machine, 1070

Parentheses ()

casts, 33

constructors, 333, 385

expressions, 17, 27

functions, 24, 197

lambda expressions, 450

methods, 30, 196

operator precedence, 17

regular expressions, 724

stacks, 587, 590

static methods, 196

vectors, 442

Parity in ripple–carry adders, 1028

Parsing

instructions, 966967

strings, 880882

Pascal’s triangle, 125

Passing arguments

references by value, 364365

static methods, 207210

PathFinder program, 683686, 690692

Paths

graphs, 674, 683692

intractability problems, 829

shortest. See Shortest paths

simple, 710

Pattern class for REs, 763

PCs. See Program counters (PCs)

PDA (pushdown automata), 755756

PDP-8 computers, 906

Peaks in terrain analysis, 167

Pell’s equation, 869

Pens

color, 150

drawings, 146

Pepys, Samuel, 88

Pepys problem, 88

Percent signs (%)

conversion codes, 131132

remainder operation, 2223

Percolation case study

adaptive plots, 314318

lessons, 318320

overview, 300301

Percolation, 303304

PercolationPlot, 315317

PercolationProbability, 310311

PercolationVisualizer, 308309

probability estimates, 310311

recursive solution, 312314

scaffolding, 302304

testing, 305308

vertical percolation, 305306

Performance

binary search trees, 647648

binary searches, 535

caveats, 509511

comparing, 508509

guarantees, 512, 627

hypotheses, 496502

importance, 702

insertion sorts, 544545

memory use, 513517

mergesort, 553

multiple parameters, 511

order of growth, 503506

overview, 494495

perspective, 518

prediction, 507509

scientific method, 495502

shortest paths, 690

wrapper types, 369

Performer program, 697699

Periods (.)

classes, 227

regular expressions, 724

Permutations

inverse, 122

sampling, 9799

Phase transitions, 317

Phone books, 628

Photographs, 346

Physical systems, graphs for, 672

Pi constant, 3132

Picture library, 346347

Piecewise approximation, 148

Pigeonhole principle, 754755

Piping

connecting programs, 141

filters, 142143

Pixels in image processing, 346

Plasma clouds, 280

Playing card possibilities, 823

PlayThatTune program, 157158

PlayThatTuneDeluxe program, 213215

PlotFilter program, 146147

Plotting

array values, 246248

experimental results, 249250

function graphs, 148, 248

percolation case study, 314318

sound waves, 249

Plus signs (+)

compound assignments, 60

floating-point numbers, 2426

integers, 22

regular expressions, 731

string concatenation, 1920

Pointers

array elements, 94

handles, 371

object references, 338

safe, 366

Poisson processes, 597

Polar coordinates, 47

Polar representation, 433434

Polling, statistical, 167

Polymorphism, 448

Polynomial time, 823

Polynomial-time algorithms

intractability, 825826

P search problems, 837, 839

usefulness, 858

Polynomial-time reductions, 841843

Pop operation

reverse Polish notation, 590591

in stacks, 567568

Positional notation, 875

Post, Emil, 813814

Post correspondence problem, 813814

Postconditions in assertions, 467

Postfix notation, 590

Postorder tree traversal, 649

PostScript language, 400, 590

PotentialGene program, 336337

Pound signs (#), 769

Power method, 180181

Power source, 10031004

PowersOfTwo program, 5658

Precedence

arithmetic operators, 17

regular expressions, 724

Precision

floating-point numbers, 25, 40

printf(), 130131

standard output, 129130

Precomputed array values, 99100

Preconditions in assertions, 467

Prediction, performance, 507509

Preferred attachment process, 713

Prefix-free strings, 564

Premature optimization, 518

Preorder tree traversal, 649

Primality-testing function, 198199

Prime numbers

in factoring, 7273

Sieve of Eratosthenes, 103105

PrimeSieve program, 103105

Primitive data types, 14

memory size, 513

overflow checking, 39

performance, 369

wrappers, 457

Principle of superposition, 483

print() method, 31

arrays, 237238

impurity, 32

Out, 355

vs. println(), 8

standard output, 129130

Print statements, 5

printf() method, 129132, 355

Printing, formatted, 130132

println() method, 31

description, 5

impurity, 32

Out, 355

vs. print(), 8

standard output, 129130

string concatenation, 20

private keyword

access modifier, 384

encapsulation, 433

Probabilities, 308, 310311

Probability density function, 202203

Problem reduction

overview, 811

program equivalence, 812

Rice’s theorem, 812813

totality problem, 811812

Problem size in intractability, 824

Procedural programming style, 329

Program counters (PCs)

bus connections, 10731074

connections and timing, 1075

control lines, 10741075

interfaces, 1073

modules, 1073

overview, 1073

TOY machine, 910

Program equivalence problem, 812

Program size, 252253

Programming environments, 1094

Programming languages

indexing, 634

stack-based, 590

symbol tables, 629

Programming overview, 1

HelloWorld example, 46

input and output, 78

process, 23

Programs

connecting, 141

processing programs, 788790, 964966

Proof by contradiction, 754

Pseudo-code, 911

public keyword

access modifiers, 384

description, 228

static methods, 196

Pulses, clock, 1058

Punched cards, 940

Punched paper tape, 934938

Pure functions, 201

Pure methods, 32

Push operation

reverse Polish notation, 590591

stacks, 567568

Pushbuttons for TOY machine, 916

Pushdown automata, 755756

Pushdown stacks, 567568

Put operations

hash tables, 639

symbol tables, 624

Putnam, Hilary, 816

Q

Quad play, 273

Quadratic Koch island fractal, 803

Quadratic order of growth, 504505, 507508

Quadratic program, 2526

Quadrature integration, 449

Quaternions, 424

Question marks (?) in REs, 731

Questions program, 533535

Queue program, 592596, 604605

Queues

circular, 620

deques, 618

FIFO. See First-in first-out (FIFO) queues

overview, 566

random, 596

summary, 608

Queuing theory, 597600

Quotes (") in text, 5

R

Race conditions in flip-flops, 1050

Ragged arrays, 111

Ramanujan, Srinivasa, 86

Ramanujan’s taxi, 86

Random graphs, 695

Random numbers

fair coin flips, 5253

function implementation, 199

Gaussian, 47

impurity, 32

libraries, 232236

random sequences, 127128

Sierpinski triangles, 239240

simulations, 7273

Math.random(), 3031

Random queues, 596

Random shortcuts, 699

Random walks

Brownian bridges, 278

self-avoiding, 112115

two-dimensional, 86

undirected graphs, 712

Random web surfer case study

histograms, 177

input format, 171

lessons, 184185

Markov chains, 176, 179184

overview, 170171

page ranks, 176177

simulation, 174178

transition matrices, 172173

RandomInt program, 3334

RandomSeq program, 127128

RandomSurfer program, 175177

RangeFilter program, 140143

Ranges

binary search trees, 651

functions, 192

Ranks

binary search trees, 651

random web surfer, 176177

Raphson, Joseph, 65

Raster images, 346

Real numbers, 888890

Receivers in cryptography, 992

Recognition problem

formal languages, 722

NFAs, 744745

REs, 728729, 735, 753

Recomputation, 282283

Rectangle rule, 449

Recurrence relations, 272

Recursion, 191

base cases, 281

BSTs, 640641, 644, 649

binary searches, 533

Brownian bridges, 278280

considering, 320

convergence issues, 281282

dynamic programming, 284289

Euclid’s algorithm, 267268

exponential time, 272273

factorial example, 264265

function-call trees, 269, 271

graphics, 276277, 397

Gray codes, 273275

linked lists, 571

mathematical induction, 266

memory requirements, 282

mergesort, 550

overview, 262263

percolation case study, 312314

perspective, 289

pitfalls, 281283

recomputation issues, 282283

towers of Hanoi, 268272

Red–black trees, 648

Redirection, 139

piping, 142143

standard input, 140141

standard output, 139140

Reduced instruction set computing (RISC), 974

Reductio ab absurdum, 808

Reduction

binary search trees, 640

mergesort, 554

polynomial-time, 841843

problem, 811813

recursion, 264265

References

accessing, 339

aliasing, 363

arrays, 365

equality, 454455

garbage collection, 367

immutable types, 364, 441

linked lists, 572

memory, 367

method, 470

object-oriented programming, 330

objects, 338339

orphaned objects, 366

passing, 207, 210, 364365

performance, 369

properties, 362363

safe pointers, 366

Reflexive property, 454

Registers

implementing, 1052

machine language, 931

overview, 10511052

TOY machine, 909, 911

writing to, 10521053

Regular expressions (REs)

applications, 732736

computational biology, 732734

generalized, 730732

NFA equivalence, 750752

overview, 724725

recognition problem, 728729, 735, 753

regular languages, 725727

searches, 734736

shorthand notations, 730731

validity checking, 732

Regular languages, 723

basic operations, 723724

regular expressions. See Regular expressions (REs)

Reject states

DFAs, 738739

Turing machines, 766767

Relative entropy, 667668

Relays in circuit models, 1006

Remainder operation, 2223

Removing

array items, 569

collection items, 566, 602603

linked list items, 573574

NFA nodes, 751

queue items, 592, 596

set keys, 652

stack items, 567569

symbol table keys, 624627

Rendell, Paul, 805

Repetitive code, simplifying, 100

Representation in APIs, 431

Representing information

binary and hex, 875880

bit manipulation, 891893

characters, 894895

integer arithmetic, 884885

negative numbers, 886888

overview, 874

real numbers, 888890

strings, 880883

summary, 896

Reproducible experiments, 495

Reserved words, 16

Resetting flip-flops, 1050

Resizing arrays, 578581, 635

ResizingArrayStackOfStrings program, 578581

Resource allocation

graphs for, 673

overview, 606607

Resource-sharing systems, 606607

Return addresses, 931

return statements, 194, 196, 198

Return values

arrays as, 210

methods, 30, 196, 200, 207210

reverse Polish notation, 591

Reuse, code, 226, 253, 701

Reverse Polish notation, 590

RGB color format, 4849, 341, 371

Rice, Henry, 812

Rice’s theorem, 812813

Riemann integral, 449

Riffle shuffles, 125

Right shift operations

bitwise, 891892

TOY machine, 913

Right subtrees, 640

Right triangles, 199

Ring buffers, 620

Ring graphs, 694695, 699

Ripple–carry adders, 10281030

RISC (reduced instruction set computing), 974

Robinson, Julia, 816

Roots in binary search trees, 640

Rotation filters, 379

Roulette-wheel selection, 174

Round-robin policies, 606

Rows in 2D arrays, 106, 108

RR-format instructions, 911

Ruler program, 1920

Run-time errors, 6

Running time. See Performance

Running virtual machines, 969

RuntimeException, 466

S

Safe pointers, 366

Sample program, 9899

Sample standard deviation, 246

Sample variance, 244

Sampling

audio, 156157

function graphs, 148

scaling, 349350

without replacement, 9799

SAT problem, 832

nondeterministic TM, 836

NP-completeness, 844846, 853856

SAT program, 855856

Satisfiability, 830

boolean, 832, 836

integer linear inequality, 831

linear equation, 830

linear inequality, 831

NP-completeness, 844846, 853856

Saving audio files, 157

Scaffolding, 302304

Scale program, 349350

Scaling

drawings, 146

image processing, 349350

spatial vectors, 442443

Scientific computing, 1094

Scientific method, 494495

hypotheses, 496502

observations, 495496

Scientific notation

conversion codes, 131132

real numbers, 888889

Scope of variables, 60, 200

Screen scraping, 357359

Search problems

difficult, 837838

easy, 837

nondeterminism, 836

overview, 833

solutions, 835

subset sum, 834

TSP problem, 862

vertex cover problem, 834, 842

0/1 ILP problem, 835, 842

Searches

binary. See Binary searches

binary search trees. See Binary search trees (BSTs)

bisection, 537

breadth-first, 683, 687688, 690, 692

data mining example, 458464

depth-first, 312, 690

indexing, 634

overview, 532

regular expressions, 734736

for similar documents, 464

Secret messages, 992

Seeds for random numbers, 475

Select control lines, 1056

Self-avoiding walks, 112115, 710

Self-loops for edges, 676

Self-modifying code, 922924

SelfAvoidingWalk program, 112115

Semantics, 52

Semicolons (;)

for loops, 59

statements, 5

Sequential circuits

clocks, 10581061

description, 1008

feedback circuits, 10481049

flip-flops, 10491050

memory, 10541057

overview, 1048

registers, 10511053

summary, 10621063

Sequential searches, 535536

Server farms, 976

Servers, 606

Service rate, 597598

SET library, 652653

Sets

elementary functions, 1001

gates, 1045

graphs, 676

Julia, 427

Mandelbrot, 406409

overview, 652653

of values, 14

Setting flip-flops, 1050

Shadow variables, 419

Shannon, Claude, 1013, 1041

Shannon entropy, 378

Shapes, outline and filled, 149

Shifts

bits, 891892

circular, 375

linear feedback shift registers (LFSRs), 10001001

purpose, 898899

TOY machine, 913

short data type, 24

Shortcuts in ring graphs, 699

Shortest paths

adjacency-matrix, 692

breadth-first searches, 690

degrees of separation, 684686

distances, 687688

graphs, 674, 683

implementation, 691

P search problems, 829, 839

performance, 690

single-source clients, 684

trees, 688689

Shuffling arrays, 97

Sicherman dice, 259

Side effects

arrays, 208210

assertions, 467

importance, 217

methods, 32, 126, 201

Sierpinski triangles, 239240

Sieve of Eratosthenes, 103105

Sign-and-magnitude, 886

Sign extension convention, 899

Signatures

constructors, 385

methods, 30, 196

overloading, 198

Similarity measures, 462

Simple paths, 710

Simplex method, 831

Simulations

coupon collector, 174178

dice, 121

gambler’s ruin, 6971

Let’s Make a Deal, 8889

load balancing, 606607

M/M/1 queues, 598600

Monte Carlo, 300, 307308

n-body. See N-body simulation

random web surfer, 174178

Single-line comments, 5

Singles quotes (’), 19

Singly linked lists, 571

Sipser, Michael, 780

Six degrees of separation, 670

Size

arrays, 578581, 635

binary search trees, 651

modules, 319

paper, 294

problems, 495, 824

program, 252253

symbol tables, 624

words, 874, 897

Sketch program, 459462

Sketches

comparing, 462463

computing, 459460

hashing, 460

overview, 458459

Slashes (/)

comments, 5

floating-point numbers, 2426

integers, 2223

Slide rules, 907908

Small-world case study. See Graphs

Small-world phenomenon, 670, 693

SmallWorld program, 696

Smith–Waterman algorithm, 286

Social network graphs, 672

Sorts

Arrays.sort(), 559

frequency counts, 555557

insertion, 543549

lessons, 558

mergesort, 550555

overview, 532

P search problems, 839

Sound. See Standard audio

Sound waves

plotting, 249

superposition of, 211215

Source vertices, 683

Space-filling curves, 425

Spaces, 10

Space–time tradeoff, 99100

Sparse matrices, 666

Sparse small-world graphs, 693

Sparse vectors, 666

Spatial vectors, 442445

Specification problem

APIs, 430

formal languages, 722

programs, 596

Speed

clocks, 1058

in performance, 507508

Spider traps, 176

Spira mirabilis, 398

Spiral program, 398399

Spirographs, 167

Split program, 358, 360

Spreadsheets, 108

Sqrt program, 6567

Square brackets ([])

arrays, 91, 106

regular expressions, 731

Square roots

computing, 6567

double value, 25

Squares, Albers, 341342

Squaring Markov chains, 179180

SR flip-flops, 1050

ST library, 625627

Stable circuits with feedback, 1049

Stack program, 583585

StackOfStrings program, 568

StackOverflowError, 282

Stacks

arithmetic expression evaluation, 586589

arrays, 568570, 578581

function calls, 590591

linked lists, 574576

overview, 566

parameterized types, 582586

pushdown, 567568

stack-based languages, 590

summary, 608

Standard audio

concert A, 155

description, 126, 128129

music example, 157158

notes, 156

overview, 155

sampling, 156157

saving files, 157

summary, 159

Standard deviation, 246

Standard drawing

control commands, 145146

description, 126, 128129

double buffering, 151

filtering data to, 146147

function graphs, 148

outline and filled shapes, 149

overview, 144145

summary, 159

text and color, 150

Standard input

arbitrary size, 137138

description, 126, 128129

formatted, 135

interactive, 135136

machine language, 936938

multiple streams, 143

overview, 132133

redirecting, 140141

summary, 159

typing, 134

virtual machines, 969970

Standard output

description, 127

formatted, 130132

machine language, 934936

multiple streams, 143

overview, 129130

piping, 141143

redirecting, 139140

summary, 159

virtual machines, 969970

Standard statistics, 244250

Standards, API, 429

Start codons, 336

Statements

assignment, 17

blocks, 50

declaration, 1516

methods, 5

States

DFAs, 738739

NFAs, 744746

objects, 340

Turing machines, 766772

virtual machines, 968

Static methods, 191192

accessing, 227229

arguments, 197

for code organization, 205206

control flow, 193195

defining, 193, 196

function-call traces, 195

function calls, 197

implementation examples, 199

vs. instance, 340

libraries. See Libraries

overloading, 198

passing arguments, 207210

returning values, 207210

Side effects, 201

summary, 215

superposition example, 211215

terminology, 195196

variable scope, 200

Static variables, 284

Statistical polling, 167

Statistics, 244250

StdArrayIO library, 237238

StdAudio library, 128129, 155

StdDraw library, 128129, 144145, 150, 154

StdIn library, 128129, 132133

StdOut library, 129131

StdRandom program, 232236

StdStats program, 244247

StockAccount program, 410413

StockQuote program, 358359

Stop codons, 336

Stopwatch program, 390391

Store instruction, 938, 1080

Stored-program computers, 922924

Streams

input, 354355

output, 355

screen scraping, 357359

Stress testing, 236

Strings and String data type

alphabet symbols, 718

API, 332333

binary, 718719

circular shifts, 375

concatenation, 1920, 723724

conversion codes, 131132

conversions, 21, 453

description, 1415

genomics application, 336340

immutable types, 439440

input, 133

internal storage, 37

invoking instance methods, 334

memory, 515

objects, 333334

overview, 331

parsing, 880882

prefix-free, 564

representation, 882883

as sequence of characters, 19

shortcuts, 334335

string replacement systems, 795

unions, 723

variables, 333

vertices, 675

working with, 1921

Strogatz, Stephen, 670, 693, 713

Structured programming, 926

Stub methods, 303

Subclassing inheritance, 452457

Subgraphs, induced, 705

Subset sum problem

intractability, 827828

NP, 834, 838

Subtraction

floating-point numbers, 2426

integers, 22

negative numbers, 887

Subtrees, 640, 651

Subtyping inheritance, 446451

Sum-of-powers conjecture, 89

Sum-of-products

adders, 1028

boolean representation, 996997

circuits, 10241027

Sums, finite, 6465

Superclasses, 452

Superposition

force vectors, 483

sound waves, 211215

Swirl filters, 379

Switch control lines, 1005

Switch statements, 7475

Switches

bus muxes, 1036

circuit models, 1002, 10051006

demultiplexers, 1022

gates, 1013

multiplexers, 1020

TOY machine, 916917

Switching circuit analysis, 1007

Switching time of gates, 1013

Symbol tables

APIs, 625627

BSTs. See Binary search trees

dictionary lookup, 628632

graphs, 676

hash tables, 636639

implementations, 635636

indexing, 632634

machine language, 944

overview, 624625

perspective, 654

sets, 652653

Symbolic names in assembly, 981

Symbols

definition, 757

description, 718719

DFA, 738

NFA, 744

regular expressions, 724

Turing machines, 766767

Symmetric order in BSTs, 640

Symmetric property, 454

Syntax errors, 1011

T

Tables

of functions, 907908

hash, 636639

symbol. See Symbol tables

Tabs

compiler considerations, 10

escape sequences, 19

Tape and tape readers

DFAs, 738739

Turing machines, 766769, 774776

Tape program, 776

Taylor series approximations, 204

Templates, 50

TenHellos program, 5455, 60

Terminal windows, 127

Terms, glossary for, 10971101

Terrain analysis, 167

Testing

for bugs, 318

importance, 701

percolation case study, 305308

Text. See also Strings and String data type

drawings, 150

printing, 5, 10

Text editors, 3

Theory of computing, 715717

this keyword, 445

Thompson, Ken, 735

3n+1 problem, 296297

ThreeSum program, 497502

Throwing exceptions, 465466

Thue word problem, 819

Ticks, clock, 1058

Tilde notation, 500

Tildes (~)

bitwise operations, 891

boolean type, 991

frequency analysis, 500

Time

exponential, 272273, 823

performance. See Performance

polynomial, 823

Stopwatch timers, 390391

TimePrimitives program, 519

Timesharing, 965

Tools, building, 320

Top-level domains, 375

toString() method

Charge, 383, 387

Color, 343

Complex, 403, 405

Convert, 881882

Counter, 436437

description, 339

Graph, 678679

linked lists, 574, 577

Object, 453

Sketch, 459

Tape, 776

Vector, 443

Total orderings, 546

Totality problem, 811812

Towers of Hanoi problem, 268272

TOY machine

arithmetic logic unit, 910

conditionals and loops, 918921

family of computers, 972977

fetch–increment–execute cycle, 910911

first program, 914915

historical note, 907908

instruction register, 910

instructions, 909, 911913

in Java, 966972

machine-language programming. See Machine-language programming

memory, 908909

operating, 916917

overview, 906907

program counter, 910

registers, 909

stored-program computer, 922924

virtual. See Virtual machines

von Neumann machines, 924925

TOY program, 967

TOY-8 machine, 974975

basic parameters, 1070

control circuit, 10801082

CPU, 10761080

instruction set, 10701071

perspective, 10841087

sum.toy program, 10711072, 10821083

TOY-64 machine, 973974

Tracing

function-call, 195

programs with random(), 103

variable values, 18, 5657

Transfer of control, 193195

Transistors, 1006

Transition matrices, 172173

Transition program, 172173

Transitions

DFAs, 738739

NFAs, 744746

Turing machines, 766767

Transitive property

comparisons, 546

equivalence, 454

polynomial-time reduction, 843

Transposition of arrays, 120

Traveling salesperson problem, 862

Traversal

binary search trees, 649650

linked lists, 574, 577

TreeMap library, 655

Tree nodes, 269

Trees

BSTs. See Binary search trees

function-call, 269, 271

H-trees, 276277

shortest paths, 688689

Triangles

drawing, 144145

right, 199

Sierpinski, 239240

Trigonometric functions, 256

Truth tables, 2627, 988989

TSP problem, 862

Turing, Alan, 766

bio, 410411, 717

code breaking, 907

von Neumann influenced by, 924925

Turing-complete models, 794

Turing machines

binary adders, 771

binary incrementers, 769771

compact trace format, 770

constant factor, 824

efficiency, 772

frequency count, 772773

model, 766769

overview, 766

related machines, 770771

restrictions, 792793

SAT problem, 836

universal, 789790

universal virtual, 774779

universal virtual DFAs, 789

universality. See Universality

variations, 791794

TuringMachine program, 777778

Turtle program, 394396

Twenty questions game, 135136, 533535

TwentyQuestions program, 135136

Two-dimensional arrays

description, 90

initialization, 106107

matrices, 109110

memory, 107, 516

output, 107

overview, 106

ragged, 111

self-avoiding walks, 112115

setting values, 108

spreadsheets, 108

Two’s complement, 38, 886888

Type arguments, 585, 611

Type conversions, 3435

Type parameters, 585

Type safety, 18

Types. See Data types

U

Unboxing, 457, 585586

Undirected graphs, 675

Unicode characters

description, 19

overview, 894895

strings, 37

Uniform random numbers, 199

Uninitialized variables, 94, 339

Union operation in REs, 723

Unit testing, 235

Universal models, 794797

Universal sets

elementary functions, 1001

gates, 1045

Universal Turing machines (UTMs), 789790

Universal virtual DFAs, 741743

Universal virtual TMs, 774779

Universality

algorithms, 786787

Church–Turing thesis, 790791

overview, 786

programs processing programs, 788790

Turing machine variations, 791794

universal models, 794797

virtual DFA/NFA, 788789

Universe program, 483487

Unreachable code error, 216

Unsigned integers, 884

Unsolvability proof, 810

Unsolvable problems, 430

blank tape halting problem, 820

definite integration, 816

description, 806

examples, 815

halting problem, 808810

Hilbert’s 10th problem, 816

implications, 816817

liar’s paradox, 807808

optimal data compression, 814

optimizing compilers, 814

Post correspondence, 813814

program equivalence, 812

totality, 811812

Upper bounds, 825

Upscaling in image processing, 349

UseArgument program, 78

User-defined libraries, 230

UTF-8 encoding, 895

UTMs, 789790

V

Validate program, 729

Validity checking, 732

Values

array, 9596

data types, 14, 331

passing arguments by, 207, 210, 364365

precomputed, 99100

symbol tables, 624626

Variables

assignment statements, 17

boolean, 987, 994997

compound assignments, 60

constants, 16

description, 1516

initial values, 415

inline initialization, 18

instance, 384

within methods, 196, 386388

names, 16

scope, 60, 200

shadow, 419

static, 284

string, 333

tracing values, 18

uninitialized, 339

Vector images, 346

Vector program, 443445, 515

Vectors

arrays, 92

cross products, 472

dot products, 92, 442443

matrix–vector multiplication, 110

n-body simulation, 479480

sparse, 666

spatial, 442445

vector–matrix multiplication, 110, 180

Vertex cover problem

intractability, 828

NP-completeness, 846847

NP search problems, 834, 842

Vertical bars (|)

bitwise operations, 891892

boolean type, 2627, 991

piping, 141

regular expressions, 724

Vertical OR gates, 1023

Vertical percolation, 305306

Vertices

bipartite graphs, 682

creating, 676

eccentricity, 711

graphs, 671, 674

isolated, 703

names, 675

PathFinder, 683

String, 675

Virtual machines

booting, 959960, 968969

cautions, 961963

and cloud computing, 924

description, 965

dumping, 960961

instructions, 966967

Moore’s law, 971

overview, 958959

program development, 970971

programs that process programs, 964966

running, 969

standard input, 969970

standard output, 969970

states, 968

TOY machine family, 972977

universal virtual DFAs, 742

universal virtual TM, 774779

Viruses, 963

Viterbi algorithm, 286

void keyword, 201, 216

Volatility

Black–Scholes formula, 565

Brownian bridges, 278, 280

Von Neumann, John, 906

ballistics tables, 907

ENIAC improvements, 924925

Gödel letter, 840

mergesort, 554

Von Neumann architecture, 790, 906, 924925

Voting machine errors, 436

W

Walks

random. See Random walks

self-avoiding, 112115, 710

Watson–Crick palindrome, 374

Watts, Duncan, 670, 693, 713

Watts–Strogatz graph model, 713

.wav format, 157

Wave filters, 379

Web graphs, 695

Web pages, 170

indexes searches, 634

preferential attachment, 713

Weighing objects, 540541

Weighted averages, 120

Weighted superposition, 212

while loops, 5359

examples, 61

nesting, 62

Whitelists, binary searches for, 540

Whitespace characters

compiler considerations, 10

input, 135

Wide interfaces

APIs, 430

examples, 610611

Wildcard operation in REs, 724

Wiles, Andrew, 722

Wind chill, 47

Wires

circuit models, 10021004

gates, 1013

Word ladders, 710

Words

binary representation, 875

computer, 874

memory size, 513

size, 897

Worst-case performance

big-O notation, 520521

binary search trees, 648

description, 512

insertion sort, 544

intractability, 825

NP-completeness, 852

Wrapper types

autoboxing, 585586

references, 369, 457

Write control lines

CPU, 10791080

memory bits, 1056

register bits, 1051

X

XOR circuits

in arithmetic logic units, 1031

sum-of-products, 10241025

xor (exclusive or) operation, 891892, 913

Y

Y2K problem, 435, 976

Young tableaux, 530

Z

Zero-based indexing, 92

Zero crossings, 164

Zero extension convention, 899

0/1 ILP problem, 831, 835

NP-completeness, 845846

vertex cover problem, 842

Zeros, leading, 883

ZIP codes, 435

Zipf’s law, 556