• Best of luck to the class of 2024 for their HSC exams. You got this!
    Let us know your thoughts on the HSC exams here
  • YOU can help the next generation of students in the community!
    Share your trial papers and notes on our Notes & Resources page
MedVision ad

Learning Algorithms (1 Viewer)

ezzy85

hmm...yeah.....
Joined
Nov 4, 2002
Messages
556
Gender
Undisclosed
HSC
N/A
try starting out by doing the modules you know. work on them separately. when theyre all done link them all with a main program. dont bother learning BASIC, its just extra work. dont worry, you should get the hang of it.
 

hurrotisrobbo

Cabbage
Joined
Jul 30, 2002
Messages
531
Location
Sydney, Newtown.
Gender
Male
HSC
2002
You might want to drop the C/Java - it confuzzles newbies with the 'redundant' ... = new XYZ(); (I know it's not, but it's confusing none-the-less).

I found Basic semi-useful when it came to algorithms. It helped for arrays, but instead of writing pseudocode, half the time I wrote Basic (not good for strict HSC markers).


Alright, learn these backwards:

- The difference between While, Do Until (or Do While), and For (well... maybe not For).

- Arrays. ESSENTIAL.

- Initialising your Pseudocode.
 

ezzy85

hmm...yeah.....
Joined
Nov 4, 2002
Messages
556
Gender
Undisclosed
HSC
N/A
apparantly the FOR loop for pseudocode isnt in the syllabus. in yr11 we were using them and the teacher was really strict about it. we could only use REPEAT or WHILE.
 

del

Member
Joined
Jul 8, 2002
Messages
412
Gender
Undisclosed
HSC
N/A
Originally posted by ezzy85
apparantly the FOR loop for pseudocode isnt in the syllabus. in yr11 we were using them and the teacher was really strict about it. we could only use REPEAT or WHILE.
theres mention of it in either the software specifications or the yr 11 syllabus i can't remember which... but i asked exactly the same thing last year...

it won't matter in the hsc exam which one you use as long as your control structures are okay
 

Ragerunner

Your friendly HSC guide
Joined
Apr 12, 2003
Messages
5,472
Location
UNSW
Gender
Male
HSC
2003
i undstand the concept of arrays but i don't know how to really apply it.

all i want to learn is algorithm writing in pseudocode.

and i can't really find a good place to start. like websites/textbooks
 

Ragerunner

Your friendly HSC guide
Joined
Apr 12, 2003
Messages
5,472
Location
UNSW
Gender
Male
HSC
2003
declaring an array isn't it like

DIM number(10)

name u can go from number(1) to 10 etc..

and i dunno what else to do from there :/
 

del

Member
Joined
Jul 8, 2002
Messages
412
Gender
Undisclosed
HSC
N/A
in VB yeah....

but don't use DIM in pseudocode....
 

del

Member
Joined
Jul 8, 2002
Messages
412
Gender
Undisclosed
HSC
N/A
usually something like
numbers(1 to 10) of integer

or something similar is enough to suffice.. as long as its not language specific or such
 

lbft

Geek
Joined
Dec 28, 2002
Messages
124
Location
Sydney
Gender
Male
HSC
2003
If you're really feeling lost just take a simple non-computer related problem.

Like:

Code:
[b]BEGIN[/b] make_coffee
  Empty cup
  Put coffee in cup
  Add water
  Add milk
  Stir coffee
[b]END[/b]
Then gradually refine it, introducing other things like control structures:

Code:
[b]BEGIN[/b] make_coffee
  [b]IF[/b] cup is not empty [b]THEN[/b]
    Empty cup
  [b]ENDIF[/b]
  Put coffee in cup
  Add water
  Add milk
  Stir coffee
[b]END[/b]
Just keep refining it:

Code:
[b]BEGIN[/b] make_coffee (wantmilk)
  [b]IF[/b] cup is not empty [b]THEN[/b]
    Empty cup
  [b]ENDIF[/b]
  Put coffee in cup
  Add water
  [b]IF[/b] wantmilk [b]THEN[/b]
    Add milk
  [b]ENDIF[/b]
  Stir coffee
[b]END[/b]
Code:
[b]BEGIN[/b] make_coffee (wantmilk)
  [b]IF[/b] cup is not empty [b]THEN[/b]
    Empty cup
  [b]ENDIF[/b]
  Put coffee in cup
  [b]REPEAT[/b]
    Add water
  [b]UNTIL[/b] cup is nearly full
  [b]IF[/b] wantmilk [b]THEN[/b]
    Add milk
  [b]ENDIF[/b]
  Stir coffee
[b]END[/b]
Eventually you'll end up with a rather complicated algoritm for a seemingly simple task. But it's a good algorithm practice exercise IMHO.

Once you can handle a non-computer problem then take a computer one. Say, something like "Write an algorithm which adds 100 different numbers."
 
Last edited:

Lazarus

Retired
Joined
Jul 6, 2002
Messages
5,965
Location
CBD
Gender
Male
HSC
2001
Here's an example of arrays being used in pseudocode (thanks to Bill Biddle of Epping Boys High) -

Code:
BEGIN MAINPROGRAM
	BinaryArray = Array[1..8] of integer = [128,64,32,16,8,4,2,1]
	BinaryNumber= Array[1..8] of integer = [1,1,1,1,1,1,1,1]
	[u]UpdateScreen[/u]
	Exit = False
	REPEAT
	Input MouseClick
	CASEWHERE MouseClick on
		Bin1: 		[u]ToggleBin1[/u]
		Bin2: 		[u]ToggleBin2[/u]
		Bin3: 		[u]ToggleBin3[/u]
		Bin4: 		[u]ToggleBin4[/u]
		Bin5: 		[u]ToggleBin5[/u]
		Bin6: 		[u]ToggleBin6[/u]
		Bin7: 		[u]ToggleBin7[/u]
		Bin8: 		[u]ToggleBin8[/u]
		UpDec:		[u]AddtoDec[/u]
		DownDec:	[u]SubFromDec[/u]
		UpHex:		[u]AddtoHex[/u]
		DownHex:	[u]SubFromHex[/u]
		UpASC:		[u]AddtoASC[/u]
		DownASC:	[u]SubFromASC[/u]
		ExitButton: 	Exit = True
	ENDCASE
	UNTIL Exit = True
END MAINPROGRAM
I've left out the sub-programs, as they're not really relevant.
 

Ragerunner

Your friendly HSC guide
Joined
Apr 12, 2003
Messages
5,472
Location
UNSW
Gender
Male
HSC
2003
can someone name a list of all the main words you need to know for algorithms ?

e.g.

BEGIN
END
WHILE
ENDWHILE
REPEAT
UNTIL
CASEWHERE
IF
ENDIF


what else ?
 

Ragerunner

Your friendly HSC guide
Joined
Apr 12, 2003
Messages
5,472
Location
UNSW
Gender
Male
HSC
2003
how about stuff like

read
input
output

because most of these i don't know what they do
 

Lazarus

Retired
Joined
Jul 6, 2002
Messages
5,965
Location
CBD
Gender
Male
HSC
2001
Some people just use GET and PRINT for reading/writing... there's a few different acceptable variants of pseudocode.
 

hurrotisrobbo

Cabbage
Joined
Jul 30, 2002
Messages
531
Location
Sydney, Newtown.
Gender
Male
HSC
2002
fork();

Math.pow(val, exp);


There. That should do it.

I was told that, 'officially', FOR loops aren't accepted, but it seems practically every one accepts them (they're in most programming languages, sans functional, for crying out loud).
 

Lazarus

Retired
Joined
Jul 6, 2002
Messages
5,965
Location
CBD
Gender
Male
HSC
2001
Originally posted by hurrotisrobbo
I was told that, 'officially', FOR loops aren't accepted
They're in the syllabus. Page 21.
 

ErgoSum

Member
Joined
Oct 19, 2002
Messages
61
Gender
Undisclosed
HSC
2002
For loops-aah

For loops are in the syllabys???.. grrr my teacher told me not to use em, so i didnt when i did the exam last year. its not the biggest deal in the world since FOR loops in psuedocode are just an abrieviated form of the WHILE loop.

As for learning algorithms, start off by NOT learning basic .. for the simple reason that its too close yet subtly different to psuedocode... if you learn basic then its very easy to mix up basic and psuedocode structures, plus some would argue basic dosn't exactly encourage good coding habits :) but hey im open minded.

As for learning algorithms, well when you see the problem pretend you are trying to explain to an idiot savant, someone incredibly intelligent at maths but basicly retarded at parsing(comprehending) english. Write down all the steps it would take for that person to successfully complete a problem on their own. Remember psuedocode is not a programming language! so theres no one "correct" way to write each line.

Also there are a few basic "design patterns" / "code cliches" or whatever you want to call them that you should learn. Unlike english, the humble programmer should embrace cliches at all costs... these patterns will all be in the board of studies book referenced above. Examples are traversing through an array, finding max min numbers, bubble sorting a list. Theoretically and probably also in reality, you should be able to break any hsc coding question into a sequence of design patterns able to solve the problem.

<Personal opinion> psuedocode is great for exams. Flowcharts are not. Flowcharts are inflexible, rigid and take large amounts of time to draw. By all means learn both (you have to) as they could force you to answer a question using one or another.. but flowcharts are for the weak minded! </personal opinon>

Finally my advice for learning all the sorts and searches .. do what i did, learn the basic principle, work out how to do it in psuedocode on your own, then implement a software version. Preferably make it give a graphical demonstration (using different colors for sorted, unsorted etc.) of how the algorithm works. Then look at the example in your textbook.

N.B Psuedocode is like PYTHON (despite having ENDWHILE END.. statements) indentation counts.
N.B.B programming at uni is more fun!!
Good luck
 

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

Top