0% found this document useful (0 votes)
204 views4 pages

Chapter 1.0 Introduction To Algorithm 4th Edition

The document discusses algorithms, which are sets of instructions that solve computational problems. It defines algorithms and provides examples like sorting numbers. The document also discusses how algorithms are used to solve practical problems and the importance of algorithm efficiency given the limited resources of computers.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
0% found this document useful (0 votes)
204 views4 pages

Chapter 1.0 Introduction To Algorithm 4th Edition

The document discusses algorithms, which are sets of instructions that solve computational problems. It defines algorithms and provides examples like sorting numbers. The document also discusses how algorithms are used to solve practical problems and the importance of algorithm efficiency given the limited resources of computers.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 4

Giovanni Israel Alvarez Osorio

Page. 5
Chapter 1. The role of algorithms in computing
What are algorithms? Why is the study of algorithms worthwhile? What is the role of algorithms relative
to other technologies used in computers? This chapter will answer these questions.
Algorithms is a set of mathematical instructions or rules that, especially if given to a computer, will help
to calculate an answer to a problem.
1.1 Algorithms
Informally, an algorithm is any well-defined computational procedure that takes some values, or set of
values, as input and produces some value, or set of values, as output in a finite amount of time. An
algorithm is thus a sequence of computational steps that transform the input into the output.
You can also view an algorithm as a tool for solving a well-specified computational problem. The
statement of the problem specifies in general terms the desired input/output relationship for problem
instance, typically of arbitrarily large size. The algorithm describes a specific computational procedure for
achieving that input/output relationship for all problem instance.
As an example, suppose that you need to sort a sequence of numbers into monotonically increasing order.
This problem arises frequently in practice and provides fertile ground for introducing many standard
design techniques and analysis tools. Here is how we formally define the sorting problem:

Thus, given the input sequence, a correct sorting algorithm returns as output the sequence. Such an input
sequence is called an instance of the sorting problem. In general, an instance of a problem consists of the
input (satisfying whatever constraints are imposed in the problem
statement) needed to compute a solution to the problem.
Because many programs use it as an intermediate step, sorting is a fundamental operation in computer
science. As a result, you have a large number of good sorting algorithms at your disposal. Which
algorithm is best for a given application depends on -among other factors- the number of items to be
sorted, the extent to which the items are already somewhat sorted, possible restrictions on the item values,
the architecture of the computer, and the kind of storage devices to be used: main memory, disks, or even
– archaically - tapes.
An algorithm for a computational problem is correct if, for every problem instance provided as input, it
halts – finishes its computing in finite time – and outputs the correct solution to the problem instance. A
correct algorithm solves the given computational problem. An incorrect algorithm might not halt at all on
some input instances, or it might halt with an incorrect answer. Contrary to what you might expect,
incorrect algorithms can sometimes be useful, if you can control their error rate. We’ll see an example of
algorithms with a controllable error rate in Chapter 31 when we study algorithms for finding large prime
numbers. Ordinarily, however, we’ll concern ourselves only with correct algorithms.
An algorithm can be specified in English, as a computer program, or even as a hardware design. The only
requirement is that the specification must provide a precise description of the computational procedure to
be followed.
What kind of problems are solved by algorithms?
Sorting is by no means the only computational problem for which algorithms have been develop. (You
probably suspected as much when you saw the size of this book.) Practical applications of algorithms are
ubiquitous and include the following examples:

 The Human Genome Project has made great progress toward the goals of identifying all the
roughly 30,000 genes in human DNA, determining the sequences of the roughly 3 billons
chemical bases pairs that make up human DNA, storing this information in databases, and
developing tools for data analysis.
 The internet enables people all around the world to quickly access and retrieve large amounts of
information. With the aid of clever algorithms, sites on the internet are able to manage and
manipulate this large volume of data.
 Electronic commerce enables goods and services to be negotiated and exchanged electronically,
and it depends on the privacy of personal information such as credit card numbers, passwords,
and bank statements. The core technologies used in electronic commerce include public-key
cryptography and digital signatures, which are based on numerical algorithms and number theory.
 Manufacturing and other commercial enterprise often need to allocate scarce resources in the
most beneficial way. An oil company might wish to know where to place its wells in order to
maximize its expected profit.
Although some of the details of these examples are beyond the scope of this book, we do give underlying
techniques that apply to these problems and problem areas. We also show how to solve many specific
problems, including the following:

 You have a road map on which the distance each pair of adjacent intersections is marked, and you
wish to determine the shortest route from one intersection to another.
 Given a mechanical design in terms of a library of parts, where each part may include instance of
the other parts, list the parts in order so that each part appears before any part that uses it.
 A doctor needs to determine whether an image represents a cancerous tumor or benign one
 You need to compress a large file containing text so that it occupies less space. Many ways to do
so are known, including “LZW compression” which looks for repeating character sequences.
These lists are far from exhaustive (as you again have probably surmised from this book’s heft), but they
exhibit two characteristics common to many interesting algorithmic problems:
1. They have many candidate solutions, the overwhelming majority of which do not solve the
problem at hand.
2. They have practical applications. Of the problems in the above list, finding the shortest path
provides the easiest examples. A transportation firm, such as a trucking or railroad company, has
a financial interest in finding shortest paths through a road or rail network.
Not every problem solved by algorithms has an easily identified set of candidate solutions. For example,
given a set of numerical values representing samples of a signal taken at regular time intervals, the
discrete Fourier transform converts the time domain to the frequency domain.
Data structures
This book also presents several data structures. A data structure is a way to store and organize data in
order to facilitate access and modifications. Using the appropriate date structure or structures is an
important part of algorithms design. No single data structure works well for all purposes, and so you
should know the strengths and limitations of several of them.
Technique
Although you can use this book as a “cookbook” for algorithms, you might someday encounter a problem
for which you cannot readily find a published algorithm (many of the exercise and problems in this book,
for example). This book will teach you techniques of algorithm design and analysis so that you develop
algorithms on your own.
Hard problems
Most of this book is about efficient algorithms. Our usual measure of efficiency is speed: how long does
an algorithm take to produce its results? There are some problems, however, for which we know of no
algorithm that runs in a reasonable amount of time.
Alternative computing models
For many years, we could count on processor clock speeds increasing at a steady rate. Physical limitations
present a fundamental roadblock to ever-increasing clock speeds
1.2 Algorithms as a technology
If computers were infinitely fast and computer memory were free, would you have any reason to study
algorithms? The answer is yes, if for no other reason than that you would still like to be certain that your
solution method terminates and does so with the correct answer.
If computers were infinitely fast, any correct method for solving a problem would do. You would
probably want your implementation to be within the bounds of good software engineering practice (for
example, your implementation should be well designed and documented), but you would most often use
whichever method was the easiest to implement.
Of course, computers may be fast, but they are not infinitely fast. Computing time is therefore a bounded
resource, which makes it precious. Although the saying goes “Time is money”, time is even more
valuable than money: you can get back money after you spend it, but once time is spent, you can never
get it back. Memory may be inexpensive, but is neither infinite nor free.
Efficiency
Different algorithms devised to solve the same problem often differ dramatically in their efficiency. These
differences can be much more significant than differences due to hardware and software.
Algorithms and other technologies
The example above shows that you should consider algorithms, like computer hardware, as a technology.
Total system performance depends on choosing efficient algorithms as much as on choosing fast
hardware. Just as rapid advances are being made in other computer technologies, they are being made in
algorithms as well.
You might wonder whether algorithms are truly that important on contemporary computers in light of the
other advanced technologies, such as

 Advance computer architectures and fabrication technologies


 Easy to use, intuitive, graphical user interfaces (GUIs)
 Object-oriented systems
 Integrated web technologies
 Fast networking, both wire and wireless
 Machine learning
 And mobile devices
The answer is yes. Although some applications do not explicitly require algorithmic content at the
application level (such as some simple, we-based applications), many do. For example, consider a web-
based service that determine how to travel from one location to another.
Having a solid base of algorithmic knowledge and technique is one characteristic that defines that the
truly skilled programmer. With modern computing technology, you can accomplish some tasks without
knowing much about algorithms, but with a good background in algorithms, you can do much, much
more.

You might also like