0% found this document useful (0 votes)
21 views

Algorithms

An algorithm is a set of step-by-step instructions to solve a problem using logical components like input, output, and processing. Algorithms can be written narratively, with pseudocode that mimics programming syntax, or with flowcharts that arrange components sequentially. There are two categories of data used in algorithms: constants that do not change value, like mathematical or scientific values, and variables that can change based on inputs or calculations.

Uploaded by

Hano Lin
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views

Algorithms

An algorithm is a set of step-by-step instructions to solve a problem using logical components like input, output, and processing. Algorithms can be written narratively, with pseudocode that mimics programming syntax, or with flowcharts that arrange components sequentially. There are two categories of data used in algorithms: constants that do not change value, like mathematical or scientific values, and variables that can change based on inputs or calculations.

Uploaded by

Hano Lin
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 1

Algorithms

An algorithm is a set of instruction steps to solve a given problem. You are already familiar with breaking down a problem into its input, output and processing components. When you write an algorithm, you use those components in a logical sequence to solve a problem. Algorithms can be written as a narrative, or they can be written in pseudocode or by using flow chart. Writing in narrative means writing out the step-by-step solution to the problem in full sentenes. Pseudocode is language that mimics real programming language. Its commands and syntax are similar to the commands and syntax of a real program, but in more general terms. Writing an algorithm in pseudocode wll help you convert the problem into a programming language. Flowcharts are diagrams that arrange the components of a problem in a logical sequence, which helps to avoid logic errors.

Categories of data
To create an algorithm, you need to know that data can be constants or variables. Constants A constant is data that has a known value and keeps that value throughout a program. A constant does not change its value and does not depend on other factors. Here are some constants from mathematics and science. *the speed of light *the number of angles in a triangle *the value of pi () *the boiling temperature of water Constants can be any data that will not change its value throughout a process or calculation. A constant can also be a non-numerical value such as your name or address. To calculate the area of a circle you use the formula r2. You do not know what the radius is, but the value of is a constant, about 3.14. this value will not change and does not depend on the size of the circle. Variables Variables can change their value throughout a program, or do not have a known, fixed value. Examples are the temperature outdoors, the number of items bought by a shopper, and the price of an item. If you are solving a problem, variables are typically the data that is inputted by a user. Consider this problem: Add the prices of three items to get a total. We do not know the three prices that must be added. The solution will probably require a user to enter the three prices and they will depend on what the user has bought.

You might also like