Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Class notes

class notes computer

Rating
-
Sold
-
Pages
191
Uploaded on
30-01-2024
Written in
2023/2024

Introdection of java language Elements of Programming . . . . . . . . . . . . . 3 1.1 Your First Program 4 1.2 Built-in Types of Data 14 1.3 Conditionals and Loops 46 1.4 Arrays 86 1.5 Input and Output 120 1.6 Case Study: Random Web Surfer 162 Functions and Modules . . . . . . . . . . . . . 183 2.1 Static Methods 184 2.2 Libraries and Clients 218 2.3 Recursion 254 2.4 Case Study: Percolation 286 Object-Oriented Programming . . . . . . . . . . 315 3.1 Data Types 316 3.2 Creating Data Types 370 3.3 Designing Data Types 416 3.4 Case Study: N-body Simulation 456 Algorithms and Data Structures . . . . . . . . . 471 4.1 Performance 472 4.2 Sorting and Searching 510 4.3 Stacks and Queues 550 4.4 Symbol Tables 608 4.5 Case Study: Small World 650

Show more Read less
Institution
Course

Content preview

Introduction
to
Programming in Java
An Interdisciplinary Approach


Robert Sedgewick
and
Kevin Wayne


Princeton University




O N L I N E P R E V I E W




!"#$%&'(')!"*+,,,- ./01/23,,,0425,67

, Publisher Greg Tobin
Executive Editor Michael Hirsch
Associate Editor Lindsey Triebel
Associate Managing Editor Jeffrey Holcomb
Senior Designer Joyce Cosentino Wells
Digital Assets Manager Marianne Groth
Senior Media Producer Bethany Tidd
Senior Marketing Manager Michelle Brown
Marketing Assistant Sarah Milmore
Senior Author Support/
Technology Specialist Joe Vetere
Senior Manufacturing Buyer Carol Melville
Copyeditor Genevieve d’Entremont
Composition and Illustrations Robert Sedgewick and Kevin Wayne

Cover Image: © Robert Sedgewick and Kevin Wayne

Page 353 © 2006 C. Herscovici, Brussels / Artists Rights Society (ARS), New York Banque d’ Images, ADAGP / Art
Resource, NY

Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trade-
marks. Where those designations appear in this book, and Addison-Wesley was aware of a trademark claim, the
designations have been printed in initial caps or all caps.

The interior of this book was composed in Adobe InDesign.

Library of Congress Cataloging-in-Publication Data

Sedgewick, Robert, 1946-
Introduction to programming in Java : an interdisciplinary approach / by Robert Sedgewick and Kevin Wayne.
p. cm.
Includes index.
ISBN 978-0-321-49805-2 (alk. paper)
1. Java (Computer program language) 2. Computer programming. I. Wayne, Kevin Daniel, 1971- II. Title.
QA76.73.J38S413 2007
005.13’3--dc22
2007020235

Copyright © 2008 Pearson Education, Inc. All rights reserved. No part of this publication may be reproduced,
stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, photocopying,
recording, or otherwise, without the prior written permission of the publisher. Printed in the United States of
America. For information on obtaining permission for use of material in this work, please submit a written request
to Pearson Education, Inc., Rights and Contracts Department, 501 Boylston Street, Suite 900, Boston, MA 02116,
fax (617) 671-3447, or online at http://www.pearsoned.com/legal/permissions.htm.

ISBN-13: 978-0-321-49805-2
ISBN-10: 0-321-49805-4

1 2 3 4 5 6 7 8 9 10—CRW—11 10 09 08 07




!"#$%&'(')!"*+,,,0 ./01/23,,,0425,67

, Preface




T HE BASIS FOR EDUCATION IN THE last millennium was “reading, writing, and arith-
metic;” now it is reading, writing, and computing. Learning to program is an
essential part of the education of every student in the sciences and engineering.
Beyond direct applications, it is the first step in understanding the nature of com-
puter science’s undeniable impact on the modern world. This book aims to teach
programming to those who need or want to learn it, in a scientific context.
Our primary goal is to empower students by supplying the experience and
basic tools necessary to use computation effectively. Our approach is to teach stu-
dents that writing a program is a natural, satisfying, and creative experience (not
an onerous task reserved for experts). We progressively introduce essential con-
cepts, embrace classic applications from applied mathematics and the sciences to
illustrate the concepts, and provide opportunities for students to write programs
to solve engaging problems.
We use the Java programming language for all of the programs in this book—
we refer to Java after programming in the title to emphasize the idea that the book
is about fundamental concepts in programming, not Java per se. This book teaches
basic skills for computational problem-solving that are applicable in many modern
computing environments, and is a self-contained treatment intended for people
with no previous experience in programming.
This book is an interdisciplinary approach to the traditional CS1 curriculum,
where we highlight the role of computing in other disciplines, from materials sci-
ence to genomics to astrophysics to network systems. This approach emphasizes
for students the essential idea that mathematics, science, engineering, and com-
puting are intertwined in the modern world. While it is a CS1 textbook designed
for any first-year college student interested in mathematics, science, or engineer-
ing (including computer science), the book also can be used for self-study or as a
supplement in a course that integrates programming with another field.



v




!"#$%&'(')!"*+,,,5 ./01/23,,,0425,67

, Coverage The book is organized around four stages of learning to program: ba-
sic elements, functions, object-oriented programming, and algorithms (with data
structures). We provide the basic information readers need to build confidence in
writing programs at each level before moving to the next level. An essential feature
of our approach is to use example programs that solve intriguing problems, sup-
ported with exercises ranging from self-study drills to challenging problems that
call for creative solutions.
Basic elements include variables, assignment statements, built-in types of
data, flow of control (conditionals and loops), arrays, and input/output, including
graphics and sound.
Functions and modules are the student’s first exposure to modular program-
ming. We build upon familiarity with mathematical functions to introduce Java
static methods, and then consider the implications of programming with func-
tions, including libraries of functions and recursion. We stress the fundamental
idea of dividing a program into components that can be independently debugged,
maintained, and reused.
Object-oriented programming is our introduction to data abstraction. We em-
phasize the concepts of a data type (a set of values and a set of operations on them)
and an object (an entity that holds a data-type value) and their implementation
using Java’s class mechanism. We teach students how to use, create, and design data
types. Modularity, encapsulation, and other modern programming paradigms are
the central concepts of this stage.
Algorithms and data structures combine these modern programming para-
digms with classic methods of organizing and processing data that remain effec-
tive for modern applications. We provide an introduction to classical algorithms
for sorting and searching as well as fundamental data structures (including stacks,
queues, and symbol tables) and their application, emphasizing the use of the scien-
tific method to understand performance characteristics of implementations.
Applications in science and engineering are a key feature of the text. We moti-
vate each programming concept that we address by examining its impact on spe-
cific applications. We draw examples from applied mathematics, the physical and
biological sciences, and computer science itself, and include simulation of physical
systems, numerical methods, data visualization, sound synthesis, image process-
ing, financial simulation, and information technology. Specific examples include a
treatment in the first chapter of Markov chains for web page ranks and case stud-
ies that address the percolation problem, N-body simulation, and the small-world



vi




!"#$%&'(')!"*+,,,8 ./01/23,,,0425,67

Written for

Institution
Secondary school
Course
School year
1

Document information

Uploaded on
January 30, 2024
Number of pages
191
Written in
2023/2024
Type
Class notes
Professor(s)
Robert sedgewick
Contains
All classes

Subjects

$8.89
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
ammarakbar

Get to know the seller

Seller avatar
ammarakbar
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
2 year
Number of followers
0
Documents
1
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions