{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Chapter22

# Chapter22 - CHAPTER The Cost of Computing Introduction A...

This preview shows pages 1–3. Sign up to view the full content.

571 Introduction A book about computing would be incomplete without summarizing what computer programs can and cannot do. As the chapters progressed, we discussed a number of data collections and a number of operations on those data collections. In Chapter 16 we also discussed Big O, the basic technique for evaluating the computing cost of an algorithm. In this chapter, first we will summarize the computing cost of the classic operation types on the several data collections. Then we will discuss in general the subject of computability, and will conclude with a discussion of a very special class of problem—the N-P Complete problem. The Cost of Computing C H A P T E R 2 2 22.1 Algorithms Operating on Collections 22.2 Algorithm Performance Categories 22.2.1 Polynomial Algorithms 22.2.2 O(2 N ) 22.2.3 O(N!) 22.3 Unreasonable Algorithms 22.4 Tractability of Problems 22.4.1 Definitions 22.4.2 Closed versus Open Problems 22.4.3 More Definitions 22.5 N-P Complete Problems 22.5.1 Yet More Definitions 22.5.2 Illustrations 22.5.3 The Opportunity

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
572 Chapter 22 The Cost of Computing 22.1 Algorithms Operating on Collections Table 22.1 illustrates the Big O performance of the most common operations we have discussed on the common data collections. In summary, any traversal, mapping, folding, or filtering is O(N) because all the data items have to be touched to perform these operations. Inserting (the critical component of building) into unstructured collections is usually O(1) because it does not matter where in the collection the new data are placed. Searching is O(N) unless the structure facilitates a binary search, and sorting is O(N log N) unless the structure cannot support random access, in which case insertion sort must be used with O(N 2 ). The X symbols indicate that the operation is not defined for this collection. 22.2 Algorithm Performance Categories As we discussed in Chapter 16 while presenting the Big O discussion, the performance of algorithms really does not matter for small amounts of data. However, in the information age in which we now live, we are confronted daily with enormous amounts of data, and computer scientists are busy polishing algorithms to process these massive amounts of data efficiently. For example, it is only in recent years that the telephone company has made national telephone directories searchable. Before, you had to know the area code before you could ask for a person’s phone number because the national listing was too cumbersome to search. Even with the best algorithms available, however, there are cases where exact solutions are not computable in reasonable amounts of time. 22.2.1 Polynomial Algorithms We tend to think of algorithms where the Big O has N to a constant power as being “OK.” However, consider some algorithm that is O(N 5 ). With 256 items of data and a processor, the computer performs one operation in a Operation Insert Traverse Filter Map Search Sort Fold N N N N Log N 1 N N N N N Log N N N Log N N 1 X N N X X N 1 N X N N X N Log N N N N Log N X N X N X N N X N X X X X N X X 1 N N N N N 2 N Array Sorted
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern