Question about algorithms (1 Viewer)

ldiebold

New Member
Joined
Dec 21, 2008
Messages
1
Gender
Male
HSC
2009
Yes, I did look in the "Your Essential Guide to Algorithms" thread, but I want to be sure,

Are for loops accepted in pseudocode? they aren't in the specifications document, but most people seem to think they are valid. They definitely should be, as they're better than whiles if you can use both.

Also, is ELSEIF valid, or would you be encouraged to use a casewhere?

Do you always have to use BEGIN SUBPROGRAM LinearSearch(...) or can you jsut use BEGIN LinerSearch(...)

Can you just use > rather than 'greater than' and >= (or the actual hand written one) rather than 'greater than or equal to'. Also, is their a valid symbol for 'not equal to' e.g. '!=' ?

Finally, are 'AND' and 'OR' for an if statement (i.e. choice = light AND switch = on THEN...) keywords?

Thanks in advance, Elliot
 

sidereal

Member
Joined
Feb 15, 2008
Messages
38
Location
Canberra
Gender
Male
HSC
2009
Uni Grad
2013
the key with psuedocode questions is that you're trying to communicate that you know how to perform the task programatically. it's not hugely important whether your "programming" is using only available language structures and keywords.

if you look back through the past hsc papers you'll see that even the exams are hugely inconsistent with regards to their psuedocode. don't stress out too much about whether or not you're following the specifications. as long as you make it obvious what you're doing, you're fine. if you think it's getting confusing, don't hesitate at all to fall back to english prose ( IF the lightswitch is on THEN ).

so to answer your questions one by one:
1. FOR loops are fine
2. ELSEIF is fine
3. either is fine, if you're writing more than one module in response to a single question i would use "SUBPROGRAM" on the appropriate modules just to distinguish between your mainline and modules. make sure you underline the name of the module.
4. < and > are fine for less/greater. <= and ≤ are both fine for greater than/equal to, but i would stick to <= just for readability to make it immediately clear. not equal to is != or <>, either is fine. as a general caution though, if you choose to write the symbols, make sure they are legible - this means don't go and write over mistakes by pressing your pen down harder.
5. AND and OR are fine. make sure to put things in brackets if your conditionals are getting confusing [ e.g. IF a = true AND (b = true OR c = true) as opposed to IF a = true AND b = true OR c = true ]

hope that helps
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top