Pseudocode lets an algorithm be written clearly without committing to a particular programming language. It keeps only the notation needed for the task, so attention can stay on the instructions rather than punctuation or language-specific rules. section 4.2
A word search can begin by defining search with a position parameter, checking that the word still fits in the text, comparing at that position, printing a match, and moving forward one character. A separate compare algorithm tests characters until it reaches the word’s end or finds a mismatch. section 4.2
Small conventions make the instructions readable:
- Use keywords such as define, if, then, return, print, and length for actions with fixed meanings. section 4.2
- Use a parameter such as pt to track a changing value, here the current text position. section 4.2
- Indent instructions that happen only when a condition is true. section 4.2
Listing 4.9 The whole program
1 define compare pt pw 2 if pw = length W then return true 3 if T[pt] = W[pw] then compare (pt + 1) (pw + 1) 4 return false 5 6 define search pt 7 if pt + length W <= length T then 8 if compare pt 0 then print pt 9 search (pt + 1)
This complete listing joins the search and comparison routines into one compact word-search algorithm. section 4.2





