Algorithms: Pseudocode, Flowcharts, Trace Tables

advertisement
Algorithms
Pseudocode, Flowcharts and Trace Tables
- Algorithm - a set of step-by-step instructions used to solve a problem or perform
a task. ex: A recipe for baking a cake -it tells you what steps to follow to get the
nal result.
- Dry-running an algorithm - manually going through its steps using a trace table
to track variable values. It helps programmers plan and test algorithms before
coding and is useful for nding logic errors by checking the code’s behaviour
step-by-step.
- Trace Table - a table used to store the values of each variable within an
algorithm. Each time a variable changes value, this gets recorded in the trace
table. Trace-tables contain a column for each variable in the algorithm and often
an additional column to show any outputs generated by the
algorithm when it proceeds.
- Flowchart - shows diagrammatically the steps required for
a task (sub-system) and the order that they are to be
performed. These steps together with the order are called
an algorithm.
- Pseudocode - a simple method of showing an
algorithm, using English-like words and
mathematical operators that are set out to look like
a program.
Designing a Trace Table
fi
Note: When the rst line
of code executes number
= print("Enter a
1
number") - assume the
user enters the integer 5.
fi
fi

Dienstag, 7. Oktober 2025
Download