{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

D-Math-W05-Ch4

# D-Math-W05-Ch4 - SHEN'S CLASS NOTES-191 Chapter Four...

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

SHEN’S CLASS NOTES-191 1 Chapter Four Algorithms 4.1 Introduction An algorithm is a well-defined computational procedure to solve a computational problem (or problem for short). An algorithm must be correct. A good algorithm must be readable, time-efficient, space- efficient. A problem defines the requirements that valid output values must satisfy for a given set of input values. Usually, we are only interested in those problems that allow infinitely many different sets and sizes of input values.

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

View Full Document
SHEN’S CLASS NOTES-191 2 For example, the sorting problem takes n numbers as input set and requires the n numbers be arranged in descending or ascending order as the valid output, where the n can be any positive integer. For a particular set of input values, the problem is referred as an instance of the problem. Therefore, a problem must contain infinitely many instances. Solving a problem is to find a valid output for any given input, which is done by an algorithm. Relationship Between an Algorithm and A program A program is a piece of code written in a particular language such as Pascal, C, C++, Java, or even some assembly language. Therefore, programs are language dependent or even machine dependent. A program can often be viewed as a detailed implementation of an algorithm with some limitations such as memory capacity, the largest number allowed, the largest size of an array, etc.