Search code examples
definitionpseudocode

Pseudocode: a clear definition?


The following code is an example of what I think would qualify as pseudocode, since it does not execute in any language but the logic is correct.

string checkRubric(gpa, major)
    bool brake = false
    num lastRange
    num rangeCounter
    string assignment = "unassigned"
    array bus['business']= array('person a'=>array(0, 2.9), 'person b'=>array(3, 4))
    array cis['computer science']= array('person c'=>array(0, 2.9), 'person d'=>array(3, 4))
    array lib['english']= array('person e'=>array(0, 4))
    array rubric = array(bus, cis, lib)

foreach (rubric as fieldAr)
    foreach (fieldAr as field => advisorAr)
        if (major == field)
            foreach (advisorAr as advisor => gpaRangeAr)
                    rangeCounter = 0
                foreach (gpaRangeAr as gpaValue)
                    if (rangeCounter < 1)
                        lastRange = gpaValue
                    else if (gpa >= lastRange && gpa <= gpaValue)
                        assignment = advisor
                        brake = true
                        break
                    endif
                    rangeCounter++
                endforeach
                if (brake == true)
                    break
                endif
            endforeach
            if (brake == true)
                break
            endif
        endif
    endforeach
    if (brake == true)
        break
    endif
endforeach
return assignment

For the past couple of weeks I've been trying to create a clear definition of what pseudocode actually is. Is it relative to the programmer or is there an actual clearcut syntax? I say pseudocode is any code that does not execute, how about you? Thanks (links to this subject welcome)


Solution

  • There is no fixed definition of pseudocode. It's any notation that you expect your audience to understand to get your point across. The important idea is that it is intended for humans to read, not computers, so it doesn't have to be precise. You can include the details that are important to your exposition, and omit the ones that are not.