• Complain

George T. Heineman - Algorithms in a Nutshell: A Desktop Quick Reference

Here you can read online George T. Heineman - Algorithms in a Nutshell: A Desktop Quick Reference full text of the book (entire story) in english for free. Download pdf and epub, get meaning, cover and reviews about this ebook. year: 2015, publisher: OReilly Media, genre: Children. Description of the work, (preface) as well as reviews are available. Best literature library LitArk.com created for fans of good reading and offers a wide selection of genres:

Romance novel Science fiction Adventure Detective Science History Home and family Prose Art Politics Computer Non-fiction Religion Business Children Humor

Choose a favorite category and find really read worthwhile books. Enjoy immersion in the world of imagination, feel the emotions of the characters or learn something new for yourself, make an fascinating discovery.

George T. Heineman Algorithms in a Nutshell: A Desktop Quick Reference

Algorithms in a Nutshell: A Desktop Quick Reference: summary, description and annotation

We offer to read an annotation, description, summary or preface (depends on what the author of the book "Algorithms in a Nutshell: A Desktop Quick Reference" wrote himself). If you haven't found the necessary information about the book — write in the comments, we will try to find it.

Creating robust software requires the use of efficient algorithms, but programmers seldom think about them until a problem occurs. This updated edition of Algorithms in a Nutshell describes a large number of existing algorithms for solving a variety of problems, and helps you select and implement the right algorithm for your needswith just enough math to let you understand and analyze algorithm performance.

With its focus on application, rather than theory, this book provides efficient code solutions in several programming languages that you can easily adapt to a specific project. Each major algorithm is presented in the style of a design pattern that includes information to help you understand why and when the algorithm is appropriate.

With this book, you will:

  • Solve a particular coding problem or improve on the performance of an existing solution
  • Quickly locate algorithms that relate to the problems you want to solve, and determine why a particular algorithm is the right one to use
  • Get algorithmic solutions in C, C++, Java, and Ruby with implementation tips
  • Learn the expected performance of an algorithm, and the conditions it needs to perform at its best
  • Discover the impact that similar design decisions have on different algorithms
  • Learn advanced data structures to improve the efficiency of algorithms

George T. Heineman: author's other books


Who wrote Algorithms in a Nutshell: A Desktop Quick Reference? Find out the surname, the name of the author of the book and a list of all author's works by series.

Algorithms in a Nutshell: A Desktop Quick Reference — read online for free the complete book (whole text) full work

Below is the text of the book, divided by pages. System saving the place of the last page read, allows you to conveniently read the book "Algorithms in a Nutshell: A Desktop Quick Reference" online for free, without having to search again every time where you left off. Put a bookmark, and you can go to the page where you finished reading at any time.

Light

Font size:

Reset

Interval:

Bookmark:

Make
Algorithms in a Nutshell 2E
George T. Heineman
Gary Pollice
Stanley Selkow
Beijing Cambridge Farnham Kln Sebastopol Tokyo Chapter 1 Thinking - photo 1

Beijing Cambridge Farnham Kln Sebastopol Tokyo

Chapter 1. Thinking Algorithmically

Algorithms matter! Knowing which algorithm to apply under which set of circumstances can make a big difference in the software you produce. Let this book be your guide to learning about a number of important algorithm domains, such as sorting and searching. We will introduce a number of general approaches used by algorithms to solve problems, such as Divide and Conquer or Greedy strategy. You will be able to apply this knowledge to improve the efficiency of your own software.

Data structures have been tightly tied to algorithms since the dawn of computing. In this book, you will learn the fundamental data structures used to properly represent information for efficient processing.

What do you need to do when choosing an algorithm? Well explore that in the following sections.

Understand the Problem

The first step to design an algorithm is to understand the problem you want to solve. Lets start with a sample problem from the field of computational geometry. Given a set of points, P , in a two-dimensional plane, such as shown in , picture a rubber band that has been stretched around the points and released. The resulting shape is known as the convex hull , that is, the smallest convex shape that fully encloses all points in P .

Figure 1-1 Sample set of points in plane Given a convex hull for P any line - photo 2
Figure 1-1. Sample set of points in plane

Given a convex hull for P , any line segment drawn between any two points in P lies totally within the hull. Lets assume that we order the points in the hull in clockwise fashion. Thus, the hull is formed by a clockwise ordering of h points L0 , L1 , Lh-1 as shown in . Each sequence of three hull points Li , Li+1 , Li+2 creates a right turn.

Figure 1-2 Computed convex hull for points With just this information you - photo 3
Figure 1-2. Computed convex hull for points

With just this information, you can probably draw the convex hull for any set of points, but could you come up with an algorithm , that is, a step by step sequence of instructions, that will efficiently compute the convex hull for any set of points?

What we find interesting about the convex hull problem is that it doesnt seem to be easily classified into existing algorithmic domains. There doesnt seem to be any sorting, although the points are ordered in clockwise fashion around the hull. Similarly, there is no obvious search being performed, although you can identify a line segment on the hull because the remaining n-2 points are to the right of that line segment in the plane.

Naive Solution

Clearly a convex hull exists for any collection of 3 or more points. But how do you construct one? Consider the following idea. Select any three points from the original collection and form a triangle. If any of the remaining n-3 points are contained within this triangle, then they cannot be part of the convex hull. Well describe the general process in using pseudocode and you will find similar descriptions for each of the algorithms in the book.

Slow Hull Summary

Best,Average,Worst: O( n4 )

slowHull(P)foreachp0inPdoforeachp1in{P-p0}doforeachp2in{P-p0-p1}doforeachp3in{P-p0-p1-p2}doifp3iscontainedwithinTriangle(p0,p1,p2)thenmarkp3asinternalPicture 4createarrayAwithallnon-internalpointsinPdetermineleft-mostpointleftinAsortAbyangleformedwithverticallinethroughleftPicture 5returnA

Points not marked as internal are on convex hull

These angles (in degrees) range from 0 to 180.

In the next chapter we will explain the mathematical analysis that explains why this approach is considered to be inefficient. This pseudo-code summary explains the steps that will produce the correct answer for each input set (in particular, it created the convex hull in ). But is this the best we can do?

Intelligent Approaches

The numerous algorithms in this book are the results of striving for more efficient solutions to existing code. We identify common themes in this book to help you solve your problems. There many different ways to compute a convex hull. In sketching these approaches, we give you a sample of the material in the chapters that follow.

Greedy

Heres a way to construct the convex hull one point at a time:

  1. First locate and remove low , the lowest point in P .
  2. Sort the remaining n-1 points in descending order by the angle formed in relation to a vertical line through low . These angles range from 90 degrees for points to the left of the line down to -90 degrees for points to the right. pn-1 is the right-most point and p0 is the left-most point. shows the vertical line as a thick blue line, and the angles to it as light gray lines.
  3. Start with a partial convex hull formed from these three points in the order { pn-1 , low , p0 }. Try to extend the hull by considering, in order, each of the points p1 to pn-1 . If the last three points of the partial hull ever turn left, the hull contains an incorrect point that must be removed.
  4. Once all points are considered, the partial hull completes.
Figure 1-3 Hull formed using greedy approach Divide and Conquer We can - photo 6
Figure 1-3. Hull formed using greedy approach
Divide and Conquer

We can divide the problem in half if we first sort all points,

Next page
Light

Font size:

Reset

Interval:

Bookmark:

Make

Similar books «Algorithms in a Nutshell: A Desktop Quick Reference»

Look at similar books to Algorithms in a Nutshell: A Desktop Quick Reference. We have selected literature similar in name and meaning in the hope of providing readers with more options to find new, interesting, not yet read works.


Reviews about «Algorithms in a Nutshell: A Desktop Quick Reference»

Discussion, reviews of the book Algorithms in a Nutshell: A Desktop Quick Reference and just readers' own opinions. Leave your comments, write what you think about the work, its meaning or the main characters. Specify what exactly you liked and what you didn't like, and why you think so.