Question 22 (e) Was Faulty (1 Viewer)

MarkSchad

New Member
Joined
Nov 27, 2006
Messages
4
Gender
Male
HSC
2007
Did anyone else notice this? The algorithm was faulty. Once you enter the first while loop it was impossible to escape. I'll try and reconstruct the algorithm from memory to show you.

Code:
FOR Runner = 1 TO 8
    RandomLane = random number from 1 to 8 inclusive
    WHILE RunnerName(RandomLane) IS NOT NULL
        RandomLane = random number from 1 to 8 inclusive
    ENDWHILE
    INPUT name
    RunnerName(RandomLane) = name
NEXT
 
Last edited:

dezistheshit

New Member
Joined
Mar 19, 2007
Messages
1
Gender
Male
HSC
2007
bahhhh

i finished before 4

dad went crazy lol

what you all think of the test

DEF FAIL!

but easier then previous years

i found that binary multiplication hard :(
:mad1:

prolly wouldve help if i didnt go drifting b4 the exam ;)

not as hard as engineering though
 

Binaries

New Member
Joined
Feb 12, 2007
Messages
2
Gender
Male
HSC
2007
Easy, i totally enilated it multiple times except for about 3-4 questions which stumped me. How about 23 i cant remember which part it was but you had to code a sub program for the output of odd numbers and what not.

I got something like this but it isn't fully correct im sure of that

Code:
Print "1", (n/2), n
 

Tomotron

New Member
Joined
May 30, 2007
Messages
20
Gender
Male
HSC
2007
this is the exam which wont be included in my UAI thats for sure LOL

our software class did almost no work all year and this is pretty much how it was going to end...left after 1.5 hours and most of my answers were stupid.
 

zcb666

Member
Joined
Dec 6, 2006
Messages
37
Gender
Male
HSC
2007
I thought it was really easy. Theres only 1, maybe 2 questions i didn't understand. And no, i didn't notice anything was up with that algorithm :/
 

ajdlinux

Mod: ANU, ATAR/HSC Marks
Joined
Sep 15, 2006
Messages
1,890
Location
Port Macquarie / Canberra
Gender
Male
HSC
2009
I didn't notice the error, but now that you point it out it's obvious.

Still, it's only a minor thing and I don't think markers will penalise you for not noticing.
 

OneShotWill

New Member
Joined
Aug 29, 2006
Messages
6
Gender
Male
HSC
2007
uHH NO it wasnt fualty.. . it says.. while that lane has a runner in it.. get a new lane number.. it ensures that every1 gets a seperate lane.. DUH
 

ajdlinux

Mod: ANU, ATAR/HSC Marks
Joined
Sep 15, 2006
Messages
1,890
Location
Port Macquarie / Canberra
Gender
Male
HSC
2009
Actually, turns out it wasn't faulty having read last two posts and thought about it for another minute... yes, it's to ensure the lane is not in use.
 

nubix

Member
Joined
Oct 17, 2006
Messages
59
Gender
Undisclosed
HSC
2007
There's nothing wrong with it, it doesn't initialise for the first loop thingo(lost the word :=(). Then for the other ones, checks whether a lane has already been assigned. It prevents lanes from getting more than 1 person.
 
Joined
Aug 15, 2006
Messages
842
Location
Sydney, NSW
Gender
Male
HSC
2007
The algorithm is not faulty

There is only one while loop. For loops cannot be infinite because they are counted.

The while loop is a safeguard to ensure that if an index of the array already has a runner, he will not get overriden, and a new index is generated, until one is not used up, and hence that will be used.

The algorithm is as follows:

Code:
BEGIN
	FOR Runner = 1 to 8
		RandomLane = random Integer between 1 and 8 inclusive
		WHILE RunnerName (RandomLane) is not null
			RandomLane = random Integer between 1 and 8 inclusive
		ENDWHILE
		Input Name
		RunnerName (RandomLane) = Name
	NEXT
	FOR Runner = 1 to 8
		LaneNo = Runner
		Output RunnerName (Runner), "is in Lane", LaneNo
	NEXT
END
 

MarkSchad

New Member
Joined
Nov 27, 2006
Messages
4
Gender
Male
HSC
2007
Edit: Actually, I see what the problem is ... for some reason I read it as "IS NULL" even though I wrote it as "IS NOT NULL" ... good thing I fudged the answer on the exam and gave them what they wanted to hear. :p
 
Last edited:
Joined
Aug 15, 2006
Messages
842
Location
Sydney, NSW
Gender
Male
HSC
2007
The code inside the while loop generates a different RandomLine integer, which is the condition for the loop - RunnerName (RandomLane) not being null.

By default all indexes of the array are null, so the code inside the while loop won't even execute.

If it happens to generate an index which is already used, it will not be null, and so the code inside the while loop will repeat until it generates an index which is null (ie. not used up). The code inside the while loop does this - generate a new index.

WHILE RunnerName (RandomLane) is not null
RandomLane = random Integer between 1 and 8 inclusive
ENDWHILE
 

NovaAesa

Member
Joined
Jul 26, 2007
Messages
93
Location
KMC
Gender
Male
HSC
2007
Starcraftmazter said:
The code inside the while loop generates a different RandomLine integer, which is the condition for the loop - RunnerName (RandomLane) not being null.

By default all indexes of the array are null, so the code inside the while loop won't even execute.

If it happens to generate an index which is already used, it will not be null, and so the code inside the while loop will repeat until it generates an index which is null (ie. not used up). The code inside the while loop does this - generate a new index.
That sums up my thoughts precisely. No problem with the algorithm at all.
 

MarkSchad

New Member
Joined
Nov 27, 2006
Messages
4
Gender
Male
HSC
2007
Starcraftmazter said:
The code inside the while loop generates a different RandomLine integer, which is the condition for the loop - RunnerName (RandomLane) not being null.

By default all indexes of the array are null, so the code inside the while loop won't even execute.

If it happens to generate an index which is already used, it will not be null, and so the code inside the while loop will repeat until it generates an index which is null (ie. not used up). The code inside the while loop does this - generate a new index.
Yea I got it now. I wasn't acknowledging the NOT in front of the null, despite the fact that I actually wrote it multiple times.
 

Tsuska

New Member
Joined
Mar 30, 2006
Messages
28
Gender
Male
HSC
2007
Tomotron said:
this is the exam which wont be included in my UAI thats for sure LOL

our software class did almost no work all year and this is pretty much how it was going to end...left after 1.5 hours and most of my answers were stupid.
Haha sounds like us! We lost our good old teacher (he left the school to become head teacher at another school with higher pay) and got a new one who last yr also took our class as a student teacher. They're both D&T teachers...and software is definately not prime. Hmm...i get about 0% of the text book. Which is pretty much the same with all of us... Umm, and since the classes were all b4 school started, some people didn't bothere to show up. The ones that did realised that all the teacher did was look at his shares (on the stock market) and go on MSN news looking at sports etc.

Did he teach us anything? no....

And when he decides to give us his first set of notes...he spotted one of my friends on bored of studies looking at one of the HSC course summaries. Printed everyone a copy and said...study this =P...

So we all went on our computers and continued doing whatever we wanted... +P

Owell...EPIC FAIL!!!
 

NovaAesa

Member
Joined
Jul 26, 2007
Messages
93
Location
KMC
Gender
Male
HSC
2007
Whatever, I just realised he had posed what I was about to post, so I just quoted instead. :)
 

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

Top