{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

28_split_Introduction to Algorithms 2nd Edition

28_split_Introduction to Algorithms 2nd Edition -...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
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? In this chapter, we will answer these questions. 1.1 Algorithms Informally, an algorithm is any well-defined computational procedure that takes some value, or set of values, as input and produces some value, or set of values, as output . An algorithm is thus a sequence of computational steps that transform the input into the output. We can also view an algorithm as a tool for solving a well-specified computa- tional problem . The statement of the problem specifies in general terms the desired input/output relationship. The algorithm describes a specific computational proce- dure for achieving that input/output relationship. For example, one might need to sort a sequence of numbers into nondecreasing order. This problem arises frequently in practice and provides fertile ground for
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: introducing many standard design techniques and analysis tools. Here is how we formally define the sorting problem : Input: A sequence of n numbers ± a 1 , a 2 ,... , a n ² . Output: A permutation (reordering) ± a ³ 1 , a ³ 2 , ... , a ³ n ² of the input sequence such that a ³ 1 ≤ a ³ 2 ≤ ··· ≤ a ³ n . For example, given the input sequence ± 31 , 41 , 59 , 26 , 41 , 58 ² , a sorting algorithm returns as output the sequence ± 26 , 31 , 41 , 41 , 58 , 59 ² . 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. Sorting is a fundamental operation in computer science (many programs use it as an intermediate step), and as a result a large number of good sorting algorithms...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online