Tải bản đầy đủ (.pdf) (7 trang)

a0006 algorithm wiley beginning algorithm morebook vn 2606

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (373.61 KB, 7 trang )

TEAM LinG


Beginning Algorithms



Beginning Algorithms
Simon Harris and James Ross


Beginning Algorithms
Published by
Wiley Publishing, Inc.
10475 Crosspoint Boulevard
Indianapolis, IN 46256
www.wiley.com
Published 2006 by Wiley Publishing, Inc., Indianapolis, Indiana
Published simultaneously in Canada
ISBN-13: 978-0-7645- 9674-2
ISBN-10: 0-7645-9674-8
Manufactured in the United States of America
10 9 8 7 6 5 4 3 2 1
1MA/RS/RQ/QV/IN
Library of Congress Cataloging-in-Publication Data:
Harris, Simon, 1972Beginning algorithms / Simon Harris and James Ross.
p. cm.
Includes index.
ISBN-13: 978-0-7645-9674-2 (paper/website)
ISBN-10: 0-7645-9674-8 (paper/website)
1. Computer algorithms. I. Ross, James, 1968- II. Title.


QA76.9.A43H376 2005
005.1--dc22
2005022374
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, scanning or otherwise, except as permitted under Sections
107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or
authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood
Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 646-8600. Requests to the Publisher for permission should be
addressed to the Legal Department, Wiley Publishing, Inc., 10475 Crosspoint Blvd., Indianapolis, IN 46256, (317)
572-3447, fax (317) 572-4355, or online at />LIMIT OF LIABILITY/DISCLAIMER OF WARRANTY: THE PUBLISHER AND THE AUTHOR MAKE NO REPRESENTATIONS OR WARRANTIES WITH RESPECT TO THE ACCURACY OR COMPLETENESS OF THE CONTENTS OF THIS WORK AND SPECIFICALLY DISCLAIM ALL WARRANTIES, INCLUDING WITHOUT
LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE. NO WARRANTY MAY BE CREATED OR EXTENDED BY SALES OR PROMOTIONAL MATERIALS. THE ADVICE AND STRATEGIES CONTAINED HEREIN MAY NOT BE SUITABLE FOR EVERY SITUATION. THIS WORK IS SOLD WITH THE
UNDERSTANDING THAT THE PUBLISHER IS NOT ENGAGED IN RENDERING LEGAL, ACCOUNTING, OR
OTHER PROFESSIONAL SERVICES. IF PROFESSIONAL ASSISTANCE IS REQUIRED, THE SERVICES OF A
COMPETENT PROFESSIONAL PERSON SHOULD BE SOUGHT. NEITHER THE PUBLISHER NOR THE
AUTHOR SHALL BE LIABLE FOR DAMAGES ARISING HEREFROM. THE FACT THAT AN ORGANIZATION
OR WEBSITE IS REFERRED TO IN THIS WORK AS A CITATION AND/OR A POTENTIAL SOURCE OF FURTHER INFORMATION DOES NOT MEAN THAT THE AUTHOR OR THE PUBLISHER ENDORSES THE INFORMATION THE ORGANIZATION OR WEBSITE MAY PROVIDE OR RECOMMENDATIONS IT MAY MAKE.
FURTHER, READERS SHOULD BE AWARE THAT INTERNET WEBSITES LISTED IN THIS WORK MAY HAVE
CHANGED OR DISAPPEARED BETWEEN WHEN THIS WORK WAS WRITTEN AND WHEN IT IS READ.
For general information on our other products and services please contact our Customer Care Department within
the United States at (800) 762-2974, outside the United States at (317) 572-3993 or fax (317) 572-4002.
Trademarks: Wiley, the Wiley logo, Wrox, the Wrox logo, Programmer to Programmer, and related trade dress are
trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its affiliates, in the United States and other
countries, and may not be used without written permission. All other trademarks are the property of their respective owners. Wiley Publishing, Inc., is not associated with any product or vendor mentioned in this book.
Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be
available in electronic books.


Using the push() and pop() Methods (with
Stacks), 100–101
Writing the Tests (for List Searcher), 203–204

try/catch block, using in JUnit, 13

U
unbounded queue, definition of, 76
UndoableList class, implementing undo action
with, 109–113
UndoAction interface, implementing, 113
UndoDeleteAction class, using with
UndoableList class, 113
undo/redo. See also stacks
implementing with stacks, 105–106
testing, 106–113
unit tests
importance of, 11–14
overview of, 9–11
running, 13–14
unordered lists, searching, 200
unsorted list priority queue, testing and
implementing, 182–184
unsorted lists, determining positions of values in,
63–64
UnsupportedOperationException, throwing,
19, 409
upperIndex variable
using with iterative binary searcher, 210
using with recursive binary searcher, 206, 208

V
Value inner class, using with hash tables, 288
ValueIterator class, using with linked lists, 73

values
adding to hash tables, 268–269
calculating in Levenshtein word distance,
426–427
deleting from array lists, 64–65
deleting from linked lists, 72
deleting from lists, 52–55
enqueuing and dequeuing, 79–80
finding in array lists, 63–64
finding in linked lists, 71–72
finding in lists, 57–58
inserting and adding in array lists, 61–62
inserting and adding in linked lists, 69–70

popping from stacks, 104–105
retrieving and storing in lists, 50–52
searching in binary search trees, 228–230
storing and retrieving by position in array lists,
62–63
storing and retrieving in linked lists, 70–71
using enqueue and dequeue operations on, 78
values, inserting and adding in lists, 47–49
verify() method, using with list inserter, 219
vertical lines
slope of, 441
testing, 452–453
testing functionality of, 450

W
waitForNotification() method, using with


BlockingQueue, 84–85
waitForTermination() method, using with call

center simulator, 92
websites
JMP (Java Memory Profiler), 477
JUnit, 11
while loops
using with binary search tree, 258, 259
using with InsertionSortListSorter, 137
using with iterative binary searcher, 209
using with iterators, 21
using with tree maps, 343
using with tree sets, 314
white-box testing, explanation of, 10
Widget class, naming convention for unit
testing, 10
WILDCARD pattern character, using in ternary
search trees, 370
wildcards, using for pattern matching in ternary
search trees, 354, 355, 356
word distance, overview of, 426–429
_word variable, using with ternary search trees,
365
words, inserting in ternary search trees,
350–351. See also letters

X
x coordinate

determining for intersecting lines, 455–456
determining for intersection point, 457

563

Index

x coordinate


x-y coordinate system, relationship to computational geometry
x-y coordinate system, relationship to
computational geometry, 437–438
xy point comparator, testing, 459–460. See also
comparators
XYPointComparator, implementing, 460–461

564

Y
y axis
crossing, 442–443
relationship to computational geometry, 438
y coordinate
calculating for Line class, 455
determining for intersection point, 457




×