1. Trang chủ
  2. » Công Nghệ Thông Tin

Schaum’s Outline Series OF Principles of Computer Science phần 1 doc

24 268 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 24
Dung lượng 778,2 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Carl Reynolds teaches courses in database, operating systems, program-ming, and programming language theory in the RIT Computer Science Department at the Rochester Institute of Technolog

Trang 3

This page intentionally left blank

Trang 4

New York | Chicago | San Francisco | Lisbon | London | Madrid

Mexico City | Milan | New Delhi | San JuanSeoul | Singapore | Sydney | Toronto

Trang 5

Carl Reynolds teaches courses in database, operating systems,

program-ming, and programming language theory in the RIT Computer Science

Department at the Rochester Institute of Technology He has taught at the

college level for 10 years, and in the computer industry for 4 years Before

coming to RIT, Reynolds spent 19 years in the computer industry working

in technical and training capacities for both hardware and software

suppli-ers, and 6 years with a Dow Jones Industrial manufacturer creating expert

systems for machine control His interests include genetic algorithms,

expert systems, and image processing

Paul Tymann is Professor and Chair of the Computer Science Department

at the Rochester Institute of Technology He has taught both basic and

advanced programming techniques for over 15 years More recently he has

been involved with development of a new bioinformatics program at RIT

Prior to entering academia, Professor Tymann worked in industry

develop-ing control software for point-of-sale terminals For the past 5 years he has

worked in the area of bioinformatics and has completed joint software

development projects at the University of Rochester and Rutgers

University

Copyright © 2008 by The McGraw-Hill Companies, Inc All rights reserved Manufactured in the United States of America Except as permitted under the United States Copyright Act of 1976, no part of this publication may be reproduced or distributed in any form or by any means, or stored in a database or retrieval system, without the prior written permission of the publisher

0-07-151037-0

The material in this eBook also appears in the print version of this title: 0-07-146051-9.

All trademarks are trademarks of their respective owners Rather than put a trademark symbol after every occurrence of a trademarked name, we use names in an editorial fashion only, and to the benefit of the trademark owner, with no intention of infringement of the trademark Where such designations appear in this book, they have been printed with initial caps

McGraw-Hill eBooks are available at special quantity discounts to use as premiums and sales promotions, or for use in corporate training programs For more information, please contact George Hoare, Special Sales, at george_hoare@mcgraw-hill.com or (212) 904-4069

THE WORK IS PROVIDED “AS IS.” McGRAW-HILL AND ITS LICENSORS MAKE NO GUARANTEES OR WARRANTIES AS TO THE ACCURACY, ADEQUACY OR COMPLETENESS OF OR RESULTS TO BE OBTAINED FROM USING THE WORK, INCLUD- ING ANY INFORMATION THAT CAN BE ACCESSED THROUGH THE WORK VIA HYPERLINK OR OTHERWISE, AND EXPRESSLY DISCLAIM ANY WARRANTY, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE McGraw-Hill and its licensors do not warrant or guarantee that the functions contained in the work will meet your requirements or that its operation will be uninterrupted or error free Neither McGraw-Hill nor its licensors shall be liable to you or anyone else for any inaccuracy, error or omission, regardless of cause,

in the work or for any damages resulting therefrom McGraw-Hill has no responsibility for the content of any information accessed through the work Under no circumstances shall McGraw-Hill and/or its licensors be liable for any indirect, incidental, special, punitive, consequential or similar damages that result from the use of or inability to use the work, even if any of them has been advised of the possibility of such damages This limitation of liability shall apply to any claim or cause whatsoever whether such claim or cause arises in contract, tort or otherwise

DOI: 10.1036/0071460519

Trang 6

We hope you enjoy this McGraw-Hill eBook! If you’d like more information about this book, its author, or related books and websites,

please click here.

Professional

Want to learn more?

Trang 7

v

CHAPTER 1 Introduction to Computer Science 1

What Is Computer Science? 1 Computing History 4

A Roadmap 12 Review Questions 13

Definition of Algorithm 14 Example—Designing a Staircase 14 Example—Finding the Greatest Common Denominator 15 Representing Algorithms with Pseudocode 15 Characterizing Algorithms 16 Analyzing Algorithms 17 Algorithms as Technology 25 Formal Models of Computation 25 Church–Turing Thesis 28 Unsolvable Problems 28

Review Questions 29

Von Neumann Architecture 31 Data Representation 31 Computer Word Size 32 Integer Data Formats 33 Real Number Formats 34 Character Formats 35

For more information about this title, click here

Trang 8

Virtual Machines 49 Procedural Programming 49 Object-Oriented Programming 51 Scripting Languages 53 Functional Languages 56 Language Design 59 Language Syntax and Semantics 61

Review Questions 64

CHAPTER 5 Programming in Java 66

Introduction 66 Java Types 66

Java Operators 70 Java Identifiers 71 Basic Control Structures 71 Object-Oriented Programming 77 Classes and Objects 78 Object State and Behavior 78 Inheritance 79 Instance and Static Variables and Methods 79 Polymorphism 83 Interfaces 84 Error Handling 85 Input and Output 88

PrintWriter 92

Review Questions 93

Capabilities of the Hardware 95 Operating Systems History 97 Single-user OS → Network OS 98 Multiprocessor Operating Systems 98 Real-Time Operating Systems 99 Embedded Systems 99 Management of Input and Output 99 Processes and Scheduling 101 Threads 102 Synchronization 103 Semaphores 106 Monitors 108 Deadlock 111 Scheduling 114 Memory Management 116 Memory Management with Multiprogramming 116 Timesharing and Swapping 117 Virtual Memory 118

vi CONTENTS

Trang 9

File Systems 122 Summary 124 Review Questions 125

Introduction 127 Reference Model 128 Subnet (Data-Link) Layer 130 Internet (Network) Layer Protocol 131 End-to-end (Transport) Layer Protocol 132 Application Layer 133 Putting It All Together 133 The World Wide Web, HTTP, and HTML 134 Summary 137 Review Questions 138

The Ubiquitous Database 139 Database Types 139 Advantages of Using a Database 140 Modeling the Data Domain 140 Building a Relational Database from the Data Model 144 Normalization 145 SQL—Structured Query Language 147 DDL—Data Definition Language 148 DML—Data Manipulation Language 150 Stored Procedures 157 Triggers 159 Data Integrity 160 Transaction Isolation Levels 161 Accessing the Database Programmatically 162 Summary 165 Review Questions 166

Ethics Theories 169 Intellectual Property 170 Privacy 174 Encryption 175 Viruses, Worms, and Trojan Horses 175 Hackers 176 Can Computers Kill? 177 Summary 178 Review Questions 179

APPENDIX Answers to Review Questions 180

CONTENTS vii

Trang 10

This page intentionally left blank

Trang 12

This page intentionally left blank

Trang 13

CHAPTER 1

Introduction to Computer Science

WHAT IS COMPUTER SCIENCE?

Computer Science is defined in different ways by different authors Wikipedia (http://en.wikipedia.org/wiki/Computer_science) defines computer science as the collection of a variety of disciplines related to computing, both theoretical and practical: theoretical foundations of information and computation, languagetheory, algorithm analysis and development, implementation of computing systems, computer graphics, databases, data communications, etc

The US National Coordination Office for Networking and Information Technology Research and

Development (NITRD) defines computer science in a similarly broad way:

the systematic study of computing systems and computation The body of knowledge resulting from this discipline contains theories for understanding computing systems and methods; design methodology, algorithms,and tools; methods for the testing of concepts; methods of analysis and verification; and knowledge representationand implementation (http://www.nitrd.gov/pubs/bluebooks/1995/section.5.html)

Another broad definition comes from the Association for Computing Machinery (ACM) Model Curriculum.

It says that computer science is the “study of computers and algorithmic processes, including their principles,their hardware and software design, their applications, and their impact on society.”

A famous definition of computer science by Gibbs and Tucker (Gibbs and Tucker, “A Model Curriculum

for a Liberal Arts Degree in Computer Science,” Comm of the ACM, vol 29, no 3, March 1986) emphasizes

algorithm development and analysis as the central focus of computer science

It’s also a fair question to ask, “How is computer science a science?” In contrast to physics, biology, andchemistry, computer science is not based on the study of the natural world In that sense, computer science ismore like mathematics than science Some argue that computer science is really computer art (where “art”means practice) On the other hand, computer scientists do use the scientific method to propose and testhypotheses, and some very nonobvious discoveries in computer science have important real-world implications

An example, which we will discuss later, is the discovery that some important problems simply cannot be solved

by computation

Despite many variations, essentially all definitions of computer science emphasize the study of algorithms.Algorithms, in one form or another, are central to computer science Computer science combines the theoreticalconcepts of algorithm design and analysis with the practical considerations of how to implement algorithms on

a computer and solve practical problems

1

Trang 14

An algorithm defines a detailed and unambiguous sequence of actions for solving a particular problem orfor performing some task If you have ever followed a recipe when cooking, followed a set of driving directions,

or filled out an income tax form, you have worked with an algorithm

For example, at some point in time you were probably taught how to determine the greatest common divisor

(GCD) of two numbers In case you’ve forgotten, the GCD of two positive integers is the greatest integer that

is an even divisor of both numbers For example, the GCD of 42 and 30 is 6 The algorithm given below can beused to compute the GCD of two positive integers a and b:

If b is zero, then the GCD of a and b is a Algorithm ends

Set r to be the remainder obtained from the integer division of a and b

Repeat this process using b and r

Consider computing the GCD of 42 and 30 Let a= 42 and b = 30 We start the process at step 1 of thealgorithm Since b is not zero, we proceed to step 2 In step 2 we compute the remainder obtained when 42 isdivided by 30, which is 12 Step 3 instructs us to repeat the process, this time using 30 and 12 So on this secondtrip through the process a is now 30 and b is now 12 Since b is not zero, we compute the remainder of 30 and

12, which is 6, and repeat the process using 12 and 6 As before, since b is not zero, we compute the remainder

of 12 and 6 and get zero We will now repeat the process using 6 and 0 This time through, since b is now zero,

we conclude that the GCD of 42 and 30 is 6

Algorithms are essential to the way computers process information because a computer program is basically

an electronic form of an algorithm that tells the computer what specific steps to perform to carry out a specifiedtask In order to study an electronic form of an algorithm, a computer scientist must also understand the computerthat will be used to execute the steps of the algorithm The term hardware is used to describe the physical, tangible parts of a computer A keyboard, mouse, motherboard, graphics card, and processor are all examples

of computer hardware

Just as a racecar driver needs to understand the capabilities and limitations of the vehicle they are driving,

a computer scientist must also understand the hardware platform on which computing algorithms will be mented It is not enough just to “know how to drive” in the case of the racecar driver, and it is not enough just

imple-to “know algorithms” imple-to be a computer scientist An algorithm that is optimal for a particular hardware platformmay not be optimal on another

Algorithms are typically expressed in a form that can be easily understood by a human being For example,the algorithm given earlier to compute the GCD of two numbers was written using the English language so that

it would be easy for you to understand

Even though you may understand more than one language, the only language that a computer understands

is machine language Machine language is a system of codes that the computer is designed to interpret Each

word in machine language represents a simple action that can be performed by the computer For example themachine language instruction “add” instructs the computer to add together two numbers (In Chap 3 onComputer Organization, we will explain machine language in much more detail.) The set of instructions that,when executed by a computer, executes the steps of an algorithm is called a program

It is difficult for humans to work directly with machine language Machine instruction words consist ofrows of ones and zeros, typically 8, 16, 32, or 64 bits long, and sometimes varying in length Since people havedifficulty manipulating these strange codes directly, computer languages have been developed to ease theprocess of converting an algorithm into a form that the computer can act upon We refer to these languages as

higher-level languages, because the languages have been designed to allow humans to work at a “higher level”

than at the level of ones and zeros of the computer Machine language, on the other hand, is often referred to as

a low-level language Java, FORTRAN, Basic, and ADA are just a few examples of high-level languages that are

used by computer scientists to express the algorithms they have developed The act of expressing an algorithmusing a low-level or high-level language is referred to as programming

Over the years, starting in the 1950s, computer scientists have created many higher-level languages In theearly days some experts thought that it should be possible to develop one language that would be best for alluses Since then, however, computer scientists have found that language design always trades off some featuresand capabilities for others As a result, today we have many good higher-level languages, some particularlysuited to symbol manipulation, some particularly good for teaching programming, some good for matrix

2 INTRODUCTION TO COMPUTER SCIENCE [CHAP 1

Trang 15

algebra applications, some for fast one-off, one-time programs, some for mission-critical, life-dependent applications, some tuned for applications in real-time automation control, and many good ones for general-purposeuse Computer scientists study the general characteristics of computer languages and formal grammars, andusually become proficient in several or many different languages.

The term software is used to describe the set of instructions, or programs, that a computer uses to execute

an algorithm Software contains the instructions that direct the operation of the hardware The software that

makes the basic functions of the computer accessible is referred to as system software System software is

responsible for controlling and managing the hardware of a computer system, and for making the computer easy

to use for program developers as well as general users Examples of system software include operating systems,

display managers, virus scanners, language processors (called compilers or interpreters—to be discussed in thechapter on software), and device drivers

Programs such as word processors or spreadsheets are referred to as application software Application

software is used to accomplish specific tasks Application software may consist of a single program, or a smallcollection of programs that work together to accomplish a task for a user of the computer

Operating systems are particularly important and complex system software They are important because the performance of the operating system has a dramatic influence on the quality of the computer user’s experi-ence and the efficiency of the computer system as a whole In the days of simpler computing systems, in the1960s and 1970s, a company might purchase a computer without an operating system, with the intention

of writing or using its own operating system, but today one always buys an operating system when one buys

a computer

The operating system provides easy access to peripheral devices like printers and displays, a file system forstoring information like data, documents, and programs, a user interface to make it easy to start application programs, a time-of-day clock, a connection to the Internet using the standard network protocols, a set of “calls”

or “methods” that application programs can use to request services of the operating system, an efficient algorithmfor allocating memory to the various programs active at the same time, and an efficient algorithm for sharingaccess to the computer among several people and/or programs at the same time

Popular operating systems today include Microsoft Windows, Mac OS, Unix, Linux (a variety of Unix),and IBM’s MVS, among others In fact, the field of operating system development is still a very active one incomputer science Not only are operating systems becoming more complex (adding firewalls and other protections,for example), but operating systems are also becoming more diverse As simpler devices like thermostats anddishwashers come under computer control, computer scientists have created specialized “embedded systems”operating systems for those requirements

Even into the 1980s many, if not most, computers were stand-alone—not connected to one another Duringthe 1970s and 1980s computer scientists explored the advantages of computing networks and proposed

a number of different physical connections among computers, as well as different networking protocols At thetime there was hot competition among different vendors of computers, each with a different standard, and each

hoping to “lock in” customers by selling its particular networking products IBM offered System Networking

Architecture (SNA), Digital Equipment promoted DECnet, Hewlett Packard offered Distributed Systems

(DS), and Xerox offered Xerox Networking Systems (XNS) Even General Motors got into the act, with its

Manufacturing Automation Protocol (MAP) None was directly compatible with any other, but all offered

“bridges” to other systems

Today the problems for computer scientists in networking are different For the most part, the world has agreed on the IEEE 801 standards and the TCP/IP protocols for the Internet The problems now have

to do with expanding the number of Internet addresses without disrupting the operation of the older “installed base,” adapting to new and much faster physical connections such as optical fiber, increasing the speed of wireless connections, which are by nature slower and more susceptible to interference, managing larger data transfers such as movies, which also require strict real-time performance so the movie doesn’t stop midaction, and providing low-power, low-cost protocols for the ad hoc connection of hundreds or thousands ofdigital sensors

Supporting almost all applications today is database technology The dominant database model is the relational database, first offered for commercial use in the 1980s Computer scientists develop algorithms forstoring and retrieving information quickly from absolutely enormous reservoirs of data How is it, for example,

CHAP 1] INTRODUCTION TO COMPUTER SCIENCE 3

Ngày đăng: 12/08/2014, 21:22

TỪ KHÓA LIÊN QUAN

🧩 Sản phẩm bạn có thể quan tâm