商家名称 | 信用等级 | 购买信息 | 订购本书 |
算法(英文版)(第4版)(塞克威克著) | |||
算法(英文版)(第4版)(塞克威克著) |
版权页:
插图:
A potential downside to this approach is that we have to work with a specnc programming language, possibly making it difficult to separate the idea of the algorithmfrom the details of its implementation. Our implementations are designed to mitigatethis difficulty, by using programming constructs that are both found in many modernlanguages and needed to adequately describe the algorithms. We use only a small subset of Java. While we stop short of formally defining thesubset that we use, you will see that we make use of relatively few Java constructs, andthat we emphasize those that are found in many modern programming languages. Thecode that we present is complete, and our expectation is that you will download it andexecute it, on our test data or test data of your own choosing. We refer to the programming constructs, software libraries, and operating systemfeatures that we use to implement and describe algorithms as our programming model.In this section and SECTION 1.2, we fully describe this programming model. The treatment is self-contained and primarily intended for documentation and for your reference in understanding any code in the book. The model we describe is the same modelintroduced in our book An Introduction to Programming in lava: An Interdisciplinary Approach, which provides a slower-paced introduction to the material. For reference, the figure on the facing page depicts a complete Java program thatillustrates many of the basic features of our programming model. We use this code forexamples when discussing language features, but defer considering it in detail to page 46 (it implements a classic algorithm known as binary search and tests it for an application known as whitelist filtering). We assume that you have experience programmingin some modern language, so that you are likely to recognize many of these features inthis code. Page references are included in the annotations to help you find answers toany questions that you might have. Since our code is somewhat stylized and we striveto make consistent use of various Java idioms and constructs, it is worthwhile even forexperienced Java programmers to read the information in this section.