Index
Overview


The answer to the given question (page title) is no and yes, as we'll soon see.

Typos and generally syntax errors include such things as misspelled words, missing brackets, or missing closing parentheses.

Recall that the primary purpose of pseudocode is to convey logical ideas in a somewhat human-like language.

💡
Trick: Do not worry about pseudocode syntax (typo-like) errors/bugs.

This is in contrast to computer program code where we attempt to fix all types of errors.

Syntax (Typo-Type) Errors Are Not Important 💡


Syntax errors (typos) are not important in pseudocode. Let's look at an example.

Description for Example Problem
Problem Statement: Compute the sum of an array of numbers.

Given Information:

Our context includes only the following:

  • "size()" - returns size/length of array
  • get(i)" -- returns array element at index "i
  • Object "this" (understands methods "size" and "get")
Pseudocode WITHOUT Syntax Errors
Here we have pseudocode with no syntax errors.

We can see the logic is simply to iterate over the array, accumulate a sum of the elements, and return the sum.
sum() {
	//assuming we contain number elements
	let i = 0
	let sum = 0
	while (i < this.size()) {
		sum += this.get(i);
		i = i + 1
	}
	return sum;
}
Pseudocode WITH Many Small Syntax Errors
This is the same algorithm as above, but we have a number syntax errors including spelling errors, missing closing parenthesis, missing braces {}, and incorrect letter case.

However, the logic has not been impacted -- iterate over the array, accumulate a sum of the elements, and return the sum. Because it is indented, our eyes can even live without the braces "{}"

This pseudocode is just as acceptable as the pseudocode above without syntax errors .. These errors do not reduce algorithm quality (e.g. grade).
sum() {
	//assuming we contain number elements
	i = 0
	sum = 0
	while i < this.size()
		sum += this.get(i);
		i = i + 1
	rreturn Sum;
}


Other Errors Are Important 🐞


Other errors (non-typo errors like "logic errors") are important in pseudocode. Let's look at an example.

Description for Example Problem
Problem Statement: Compute the sum of an array of numbers

Given Information:

Our context includes only the following:

  • method size() - returns size/length of array
  • method get(i) -- returns array element at index "i"
  • method set(i, v) -- sets and returns value "v" into array at index "i"
  • Object "this"
  • Object "foo" (same object type as "this")
  • Assume both objects handle all the methods shown
  • Assume we are computing the sum for "this" object
Other Errors - Example 1
We have no syntax errors in this pseudocode. However, the logical behavior would not be predictable.

We are sending "size" to the wrong object, we are sending "set" rather than "get".

Notice that none of these are just "typos". The logic is not okay.

We want to fix them. These errors do reduce algorithm quality (e.g. grade).
sum() {
	//assuming we contain number elements
	let i = 0
	let sum = 0
	while (i < foo.size()) {
		sum += this.set(i, 0);
		i = i + 1
	}
	return something;
}
Other Errors - Example 2
In this code we are referencing a variable "elements" and accessing a variable "length". Neither of these are in our context.

Notice that none of these are just "typos". The logic is not okay.

We want to fix them. We want to fix them. These errors do reduce algorithm quality (e.g. grade).
sum() {
	//assuming we contain number elements
	let i = 0
	let sum = 0
	while (i < elements.length) {
		sum += this.get(i);
		i = i + 1
	}
	return sum;
}


Recap


Syntax Errors are Perfectly Acceptable
This pseudocode has syntax errors only (missing closing parentheses, typo, incorrect character case).

It is perfectly acceptable pseudocode. These errors do not reduce algorithm quality (e.g. grade).
while i < this.size()
	sum += this.get(i);
	i = i + 1
rreturn Sum;
Logic Errors Should be Corrected
This pseudocode also has non-typo (logic) errors such as referencing "foo" which is not in the context.

Another error is calling the wrong method "set".

These errors impact logic and should be corrected. These errors do reduce algorithm quality (e.g. grade).
while i < foo.size()
	sum += this.set(i, 10);
	i = i + 1
rreturn Sum;