ebook img

PASCAL plus data structures, algorithms, and advanced programming PDF

657 Pages·1985·50.93 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview PASCAL plus data structures, algorithms, and advanced programming

. Copyright © 1985 by D. C. Heath and Company. All rights reserved. No part ofthis publication may be reproduced or transluitted in any form or by any means, electronic or mechanical, including photocopy, recording, or any information storage or retrieval system, without perluission in writing from the publisher. Published siInultaneously in Canada. Printed in the United States ofAmerica. International Standard Book Number: 0-669-07239-7 Library ofCongress Catalog Card Number: 84-82073 To the next generation ofcomputer scientists N.D. To my father, Mason M. Lilly S.L. Preface Until recently there has not been much consensus among educators on what formal education is necessary for a computer professional. It has al ways beenconsideredessentialtohaveagreatdeal ofmathematicalknowl edge, as \vell as an understanding ofcomputer hardware. Software educa tion, however, often consisted ofthe teaching ofa number ofprogramming languages. The development ofprogramming techniques, it was often as sumed, was not a subjectofformal education, butratheramatterofexperi ence. This situation is analagous to an English department teaching only grammar without freshman cOlnposition, literature, or creative writing. Today the shared experience ofa generation ofprogrammers has com bined to form a body of practical and theoretical knowledge that can be taughtalong with computer languages. Software is now an area ofstudy in its own right. The evolution of this situation can be clearly seen in the progression of computer science curricula advocated by the major com puter professional organizations. Three main professional organizations represent the spectrum of com puter educators and professionals: the ACM (Association of Computing Machinery), the IEEE (Institute of Electronic and Electrical Engineers), and the DPMA (Data Processing Management Association). Each ofthese organizations has contributed greatly to computer science education over the years by publishingcurriculum guidelines that identify whata student should know upon graduation from a four-year institution ofhigher learn ing. The first curriculum guidelines were published in 1968 by the ACM. Theseguidelines assumedthatonlythose students whohadabroadmathe matical background could possibly learn computer science. Programming was considered a skill that the student was to master on his or her own, perhaps withinalaboratorysetting. In 1976the IEEE issuedguidelines for vii iii vi Preface afour-yearprogram in ComputerEngineering. Againprogrammingwas not a task to be lllastered in its own right. In 1978the ACM revised its curriculum. Forthe firsttime, programming was mentioned as a topic ofstudy. Another major change was that mathe matics was considered a co-requisite, rather than a prerequisite, of the study ofcomputing. Three things happened in 1983-1984 which solidified the trends in computer-related education: the ACM approved the revision ofCS1 (Cur riculum '78) and presented a first draft ofCS2, the IEEE revised its entire curricululn, and the curriculum for an Advanced Placement Exam in Com puter Sciences was specified by the College Boards. The correlation be tween the ACM CS1 and (draft) CS2 and the AP curriculum was extraordi narily high, and this intersection mapped quite closely onto SubjectAreas 1, 2, and 4 ofthe IEEE curricululn. Aconsensus has evolved concerning what the curriculum should be for the first yearofacomputerscience education-withinengineeringorelse where. To computereducators this is an excitingdevelopment. Pascal Plus Data Structures, Algorithms, and Advanced Programming covers the ad vanced topics in this consensus. It is designed to follow a one-semester course that is an introduction, or its equivalent, to top-down design and structured programming with Pascal. WHY THIS TEXT IS D~ffIERENT Our presentation is unique in that we stress the leading edge ofcomputer science theory and software engineering principles. These principles in clude modularization, dataencapsulation, informationhiding, dataabstrac tion, top-down design ofalgorithms and data structures in parallel, testing strategies, program verification, and proper documentation. We feel strongly that these principles can be stressed without resolting to conlplicatedlnathelnaticalnotation. Therefore,this bookassumes nocol lege-level mathematics. Even algorithln analysis and program verification areapproached intuitively. Thosestudents with amathematics background can understand Engish presentations; those students with no mathematics cannotunderstandformalisms. We intendto reach both groups ofstudents. ORGANIZATION AND CONTIENT Chapter 1 reviews the basic principles of designing computer programs. We assume that the reader has a basic knowledge ofPascal programming. The goals for writing a good program are enumerated, and a number of tools for attaining these goals are described in detail. The techniques for the top-down design of both programs and data structures are reviewed with an elnphasis on modularization and good documentation. Approaches for debugging and testillg are also discussed. Detailed sample problems illustrate these points. IIX Preface Chapter 2 describes how data structures will be studied throughout the rest ofthe book. One-diInensional arrays, two-dimensional arrays, and rec ords-three structured datatypes with which the students shouldbe famil iarfrom theirfirst course-are examinedfrom three perspectives: the logi cal level, the application or usage level, and the implementation level. The concept ofan abstract data type is illustrated in an application that uses the one-dimensional array and the record to create a string data type. Utility routines to manipulate the string data type are designed, written, and tested. The string data type defined here is used in some ofthe appli cations in later chapters, illustrating the point that once a programmer has created a user-defined data type, subsequent problems may assume this type to be "built-in." In Chapter 3 stacks are introduced to demonstrate the concept ofdata encapsulation in user-defined data structures. We develop, first, an under standing of the logical properties and operations on the structure (e.g., PUSHand POP), andsecond, one ormore implementations ofthe structure and its operations in the Pascal programming language. Finally, stacks are used in two complete programs to illustrate the real-world application of this data structure. Queues are discussed in a similarfashion in Chapter4. In addition, this chapterexamines in detail whatdesign considerations mustbe given to the choice ofa particular in1plementation. The chapter concludes with an ap plication that illustrates a queueing system in a simulation problem. Linked lists are presented in Chapters 5 and 6. The implementation level inChapter5uses an arrayofrecords; in Chapter6the dynamicimple mentation oflinked lists is discussed. We decided to present first the idea oflinkingthe elements in a listinterms ofstructures thatare alreadyfamil iar (an array ofrecords) before the introduction ofa new, language-depen dentsyntax.Aftertheconceptsandthisgeneralsolutionarefullyunderstood in Chapter 5, the syntax ofthe Pascal pointertype is presented in detail in Chapter 6, along with a discussion ofdynamic allocation. To illustrate its use, the linked list structure is implemented again using pointervariables. Doubly-linked lists, circular lists, and lists with headers and trailers are also discussed. We present recursion in Chapter7 with two goals for the student-first, to give him or her an intuitive understanding ofthe concept and a belief that recursion actually works; and second, to convey how recursion can be used to solve programming problems. Guidelines for writing recursive functions andprocedures are illustratedwith many examples, anda simple technique for verifying the correctness ofa recursive routine is presented. Since many students are wary of recursion (after having been warned to avoid its unintentional use in their first course), the presentation here is deliberately intuitive and nonmathematical. InChapter8the binarysearchtree is introducedas awayto arrange data that gives the flexibility ofa linked structure withollt the liability ofslow, sequential access. The insertion and deletion algorithms are developed in detail and implemented for a tree whose nodes are linked with pointer I x Preface variables. A nonrecursive tree traversal is presented usinga stack as a sup plementary data structure. Then recursive tree traversals are presented, illustrating how recursion can greatly simplify some programming prob lems. Chapter9is a collection ofloosely related topics. We discuss expression trees, and point out the relationship between the different tree traversals and mathematical notation. The use ofarrays to implement binary trees is presented as a lead-in to the discussion ofheaps and heapsort. The final topic in the chapter is an introduction to graphs. Chapter10is an introductionto programverification. This topic is onthe leading edge of theoretical computer science. This is written as a stand alone chapter, and may be omitted without losing continuity. However, program verification techniques will be employed by the next generation ofcomputer professionals to produce reliable software. This chapter is in tended to introduce students to a topic that they will encounter again in later courses. Chapter 11 presents a number ofsorting algorithms and asks the ques tion: Which is best? To answer this question, we introduce the analysis of algorithms; and we compare the selection sort, bubble sort, quicksort, and heapsort. Chapter 12 continues the discussion ofalgorithm analysis in the context ofsearching. Various searching algorithms are presented and ana lyzed, including sequential and binary searches and hashing techniques. In both chapters the practical considerations in choosing appropriate sort ing and searchingtechniques are balanced by the theoretical concepts be hind the idea ofmeasuring work. Chapter 13 is a summary chapter that ties together the ideas introduced in this book in a discussion ofthe "real-world" programmingenvironment. The concepts and techniques discussed throughout the previous chapters are developed to create the principles of software engineering practices thatare in use todayfor solvinglarge and complex programmingproblems. ADD~l~ONAL fEATURES ChapterGoals: Atthe beginningofeach chapterthe goals ofthatchap terare presented. These goals are then tested in the exercises and pretests at the end ofthe chapter. ChapterExercises: Attheendofeachchapter(exceptChapter 13),there is asetofpaper-and-pencilexercises totestwhetherthe chaptergoals have been attained. The complete exercise answers are in the back ofthe book. ChapterPretests: Atthe endofeachchapter(exceptChapter13)there is a test for the student to measure his or her own progress. The answers to these questions are in the Instructor's Guide.

Description:
Pascal Plus Data Structures focuses on abstract data types, their specification, their implementation, and their application. Also stresses computer science theory and software engineering principles, including modularization, data encapsulation, information hiding, data abstraction, the top-down de
See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.