O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Introduction to Programming in Java: An Interdisciplinary Approach

Book Description

Programming skills are indispensable in today’s world, not just for computer science students, but also for anyone in any scientific or technical discipline. Introduction to Programming in Java, Second Edition, by Robert Sedgewick and Kevin Wayne is an accessible, interdisciplinary treatment that emphasizes important and engaging applications, not toy problems. The authors supply the tools needed for students and professionals to learn that programming is a natural, satisfying, and creative experience, and to become conversant with one of the world’s most widely used languages.

 

This example-driven guide focuses on Java’s most useful features and brings programming to life for every student in the sciences, engineering, and computer science.

 

Coverage includes

  • Basic elements of programming: variables, assignment statements, built-in data types, conditionals, loops, arrays, and I/O, including graphics and sound
  • Functions, modules, and libraries: organizing programs into components that can be independently debugged, maintained, and reused
  • Algorithms and data structures: sort/search algorithms, stacks, queues, and symbol tables
  • Applications from applied math, physics, chemistry, biology, and computer science

Drawing on their extensive classroom experience, throughout the text the authors provide Q&As, exercises, and opportunities for creative engagement with the material. Together with the companion materials described below, this book empowers people to pursue a modern approach to teaching and learning programming.

 

Companion web site (introcs.cs.princeton.edu/java) contains

  • Chapter summaries
  • Supplementary exercises, some with solutions
  • Detailed instructions for installing a Java programming environment
  • Program code and test data suitable for easy download
  • Detailed creative exercises, projects, and other supplementary materials

Companion studio-produced online videos (informit.com/sedgewick) are available for purchase and provide students and professionals with the opportunity to engage with the material at their own pace and give instructors the opportunity to spend their time with students helping them to succeed on assignments and exams.

Table of Contents

  1. About This E-Book
  2. Title Page
  3. Copyright Page
  4. Dedication Page
  5. Contents
  6. Programs
  7. Preface
    1. Coverage
    2. Related texts
    3. Use in the curriculum
    4. Prerequisites
    5. Goals
    6. Online lectures
    7. Booksite
    8. Acknowledgments
  8. Chapter One. Elements of Programming
    1. 1.1 Your First Program
      1. Programming in Java
      2. Input and output
    2. Q&A
    3. Exercises
    4. 1.2 Built-in Types of Data
      1. Terminology
      2. Characters and strings
      3. Integers
      4. Floating-point numbers
      5. Booleans
      6. Comparisons
      7. Library methods and APIs
      8. Type conversion
      9. Summary
    5. Q&A (Strings)
    6. Q&A (Integers)
    7. Q&A (Floating-Point Numbers)
    8. Q&A (Variables and Expressions)
    9. Exercises
    10. Creative Exercises
    11. 1.3 Conditionals and Loops
      1. If statements
      2. While loops
      3. For loops
      4. Nesting
      5. Applications
      6. Other conditional and loop constructs
      7. Infinite loops
      8. Summary
    12. Q&A
    13. Exercises
    14. Creative Exercises
    15. 1.4 Arrays
      1. Arrays in Java
      2. Coupon collector
      3. Sieve of Eratosthenes
      4. Two-dimensional arrays
      5. Example: self-avoiding random walks
      6. Summary
    16. Q&A
    17. Exercises
    18. Creative Exercises
    19. 1.5 Input and Output
      1. Bird’s-eye view
      2. Standard output
      3. Standard input
      4. Redirection and piping
      5. Standard drawing
      6. Standard audio
      7. Summary
    20. Q&A
    21. Exercises
    22. Creative Exercises
    23. 1.6 Case Study: Random Web Surfer
      1. Input format
      2. Transition matrix
      3. Simulation
      4. Mixing a Markov chain
      5. Lessons
    24. Exercises
    25. Creative Exercises
  9. Chapter Two. Functions and Modules
    1. 2.1 Defining Functions
      1. Static methods
      2. Implementing mathematical functions
      3. Using static methods to organize code
      4. Passing arguments and returning values
      5. Example: superposition of sound waves
    2. Q&A
    3. Exercises
    4. Creative Exercises
    5. 2.2 Libraries and Clients
      1. Using static methods in other programs
      2. Libraries
      3. Random numbers
      4. Input and output for arrays
      5. Iterated function systems
      6. Statistics
      7. Modular programming
    6. Q&A
    7. Exercises
    8. Creative Exercises
    9. 2.3 Recursion
      1. Your first recursive program
      2. Mathematical induction
      3. Euclid’s algorithm
      4. Towers of Hanoi
      5. Function-call trees
      6. Exponential time
      7. Gray codes
      8. Recursive graphics
      9. Brownian bridge
      10. Pitfalls of recursion
      11. Dynamic programming
      12. Perspective
    10. Q&A
    11. Exercises
    12. Creative Exercises
    13. 2.4 Case Study: Percolation
      1. Percolation
      2. Basic scaffolding
      3. Vertical percolation
      4. Testing
      5. Estimating probabilities
      6. Recursive solution for percolation
      7. Adaptive plot
      8. Lessons
    14. Q&A
    15. Exercises
    16. Creative Exercises
  10. Chapter Three. Object-Oriented Programming
    1. 3.1 Using Data Types
      1. Basic definitions
      2. String-processing application: genomics
      3. Color
      4. Digital image processing
      5. Input and output revisited
      6. Properties of reference types
    2. Q&A
    3. Exercises
    4. Creative Exercises
    5. 3.2 Creating Data Types
      1. Basic elements of a data type
      2. Stopwatch
      3. Histogram
      4. Turtle graphics
      5. Complex numbers
      6. Mandelbrot set
      7. Commercial data processing
    6. Q&A
    7. Exercises
    8. Creative Exercises
    9. 3.3 Designing Data Types
      1. Designing APIs
      2. Encapsulation
      3. Immutability
      4. Example: spatial vectors
      5. Interface inheritance (subtyping)
      6. Implementation inheritance (subclassing)
      7. Application: data mining
      8. Design by contract
    10. Q&A
    11. Exercises
    12. Data-Type Design Exercises
    13. Creative Exercises
    14. 3.4 Case Study: N-Body Simulation
      1. N-body simulation
    15. Q&A
    16. Exercises
    17. Creative Exercises
  11. Chapter Four. Algorithms and Data Structures
    1. 4.1 Performance
      1. Scientific method
      2. Observations
      3. Hypotheses
      4. Order-of-growth classifications
      5. Predictions
      6. Caveats
      7. Performance guarantees
      8. Memory
      9. Perspective
    2. Q&A
    3. Exercises
    4. Creative Exercises
    5. 4.2 Sorting and Searching
      1. Binary search
      2. Insertion sort
      3. Mergesort
      4. Application: frequency counts
      5. Lessons
    6. Q&A
    7. Exercises
    8. Creative Exercises
    9. 4.3 Stacks and Queues
      1. Pushdown stacks
      2. Array implementation
      3. Linked lists
      4. Resizing arrays
      5. Parameterized data types
      6. FIFO queues
      7. Queue applications
      8. Resource allocation
    10. Q&A
    11. Exercises
    12. Linked-List Exercises
    13. Creative Exercises
    14. 4.4 Symbol Tables
      1. API
      2. Symbol-table clients
      3. Elementary symbol-table implementations
      4. Hash tables
      5. Binary search trees
      6. Performance characteristics of BSTs
      7. Traversing a BST
      8. Ordered symbol table operations
      9. Set data type
      10. Perspective
    15. Q&A
    16. Exercises
    17. Binary Tree Exercises
    18. Creative Exercises
    19. 4.5 Case Study: Small-World Phenomenon
      1. Graphs
      2. Graph data type
      3. Graph client example
      4. Shortest paths in graphs
      5. Small-world graphs
      6. Lessons
    20. Q&A
    21. Exercises
    22. Creative Exercises
  12. Context
    1. Java libraries
    2. Programming environments
    3. Scientific computing
    4. Apps and cloud computing
    5. Computer systems
    6. Theory of computing
    7. Machine learning
  13. Glossary
  14. Index
  15. APIs
  16. Code Snippets