上QQ阅读APP看书,第一时间看更新
Pseudo code
Pseudo code is a high-level design of a program or algorithm. Sequence and selection are two constructs used in pseudo code. Pseudo code is easier than a flow chart visualizes the algorithm while pseudo code can be easily modified and updated. Errors in design can be caught very early in pseudo code. This saves the cost of fixing defects later.
To give an example, we want to find the max value in an array of length n. The pseudo code will be written as follows:
maximum(arr) {
n <- len(arr)
max <- arr[0]
for k <- 0,n do {
If arr[k] > max {
max <- arr[k]
}
}
return max
}
Now that we know the different ways to represent the algorithm, let's take a look at how we can monitor its complexity and performance in the next section.