[Year 12 SofDev] Help needed

Mike Brookes mikebr at tpg.com.au
Wed May 25 19:44:27 EST 2011


Hi all

A good algorithm to check student's skills. Only problem is that initial 
green and red values must be given.
Would include colour[4] values so as not to give the game away.

Below is an example desk check - excuse the alignment Excel does not 
paste too well into an email
Have attached the spreadsheet which uses formulae to calculate values so 
you can change the initial values to something that will give one of the 
answers (I assumed colour values are from 0 to 255)

Sample desk check
algorithm 	
	
	
	
	
	
	
	
	
	
	
	
Line number 	Step 	
	
	
	
	
	
	
	
	
	
	
	
1 	BEGIN 	
	
	
	
	
	
	
	
	
	
	
	
2 	SET TOTAL TO 0 	
	
	
	
	
	
	
	
	
	
	
	
3 	SET COUNTER TO 1 	
	
	
	
	
	
	
	
	
	
	
	
4 	WHILE COUNTER < 4 	
	
	
	
	
	
	
	
	
	
	
	
5 	TOTAL = TOTAL + COLOUR [COUNTER] . GREENVALUE 	
	
	
	
	
	
	
	
	
	
	
	
6 	ADD 1 TO COUNTER 	
	
	
	
	
	
	
	
	
	
	
	
7 	ENDWHILE 	
	
	
	
	
	
	
	
	
	
	
	
8 	WHILE COUNTER < 4 	
	
	
	
	
	
	
	
	
	
	
	
9 	TOTAL = TOTAL + COLOUR [COUNTER] . REDVALUE 	
	
	
	
	
	
	
	
	
	
	
	
10 	ADD 1 TO COUNTER 	
	
	
	
	
	
	
	
	
	
	
	
11 	ENDWHILE 	
	
	
	
	
	
	
	
	
	
	
	
12 	PRINT TOTAL 	
	
	
	
	
	
	
	
	
	
	
	
13 	END 	
	
	
	
	
	
	
	
	
	
	
	

	
	
	
	
	
	
	
	
	
	
	
	
	

	
	colour[1] 	colour[2] 	colour[3] 	colour[4] 	colour[1] 	colour[2] 
colour[3] 	colour[4] 	
	
	
	
Line number 	Step 	.greenvalue 	.greenvalue 	.greenvalue 	.greenvalue 
.redvalue 	.redvalue 	.redvalue 	.redvalue 	total 	counter 	result of 
test 	output

	initial values 	47 	79 	19 	133 	95 	208 	93 	40 	
	
	
	
1 	BEGIN 	
	
	
	
	
	
	
	
	
	
	
	
2 	SET TOTAL TO 0 	
	
	
	
	
	
	
	
	0 	
	
	
3 	SET COUNTER TO 1 	
	
	
	
	
	
	
	
	
	1 	
	
4 	WHILE COUNTER < 4 	
	
	
	
	
	
	
	
	
	
	TRUE 	
5 	TOTAL = TOTAL + COLOUR [COUNTER] . GREENVALUE 	
	
	
	
	
	
	
	
	47 	
	
	
6 	ADD 1 TO COUNTER 	
	
	
	
	
	
	
	
	
	2 	
	
4 	WHILE COUNTER < 4 	
	
	
	
	
	
	
	
	
	
	TRUE 	
5 	TOTAL = TOTAL + COLOUR [COUNTER] . GREENVALUE 	
	
	
	
	
	
	
	
	126 	
	
	
6 	ADD 1 TO COUNTER 	
	
	
	
	
	
	
	
	
	3 	
	
4 	WHILE COUNTER < 4 	
	
	
	
	
	
	
	
	
	
	TRUE 	
5 	TOTAL = TOTAL + COLOUR [COUNTER] . GREENVALUE 	
	
	
	
	
	
	
	
	145 	
	
	
6 	ADD 1 TO COUNTER 	
	
	
	
	
	
	
	
	
	4 	
	
4 	WHILE COUNTER < 4 	
	
	
	
	
	
	
	
	
	
	FALSE 	
8 	WHILE COUNTER <4 	
	
	
	
	
	
	
	
	
	
	FALSE 	
12 	PRINT TOTAL 	
	
	
	
	
	
	
	
	
	
	
	145
13 	END 	
	
	
	
	
	
	
	
	
	
	
	


Mike Brookes
Semi retired gentleman of leisure
Copperfield College

On 25/05/2011 11:43 AM, Brett Groves wrote:
> Hi all,
>
> Wondering if some kind soul who is good with desk checks / pseudo code 
> can help me out here. We are about to commence OC2 (running a week 
> late) and I have given my students some algorithms to evaluate for 
> revision. On one in particular I realised I made an error of logic 
> when evaluatiing it myself and have now confused my self to point of 
> frustration. It's the one below. It has two count loops which it uses 
> to select data in an array but they both have identical conditions. As 
> I am currently reading it values will never be passed to the second 
> loop as the evaluation condition that ends the first loop will also 
> end the second???? Scratches head......sure I'm failing to see 
> obvious! Can anyone help pls
>
> Brett
>
> *Question 12:*
>
> The following diagram shows the contents of an array of records used 
> for mixing colours.
>
> The name of the array is 'COLOUR'.
>
> The algorithm below is used to calculate colour values, using an array.
>
> BEGIN
>
> SET TOTAL TO 0
>
> SET COUNTER TO 1
>
> WHILE COUNTER < 4
>
> TOTAL = TOTAL + COLOUR [COUNTER] . GREENVALUE
>
> ADD 1 TO COUNTER
>
> ENDWHILE
>
> WHILE COUNTER < 4
>
> TOTAL = TOTAL + COLOUR [COUNTER] . REDVALUE
>
> ADD 1 TO COUNTER
>
> ENDWHILE
>
> PRINT TOTAL
>
> END
>
>
> What will be the output of this algorithm?
>
> (A) 10
>
> (B) 11
>
> (C) 18
>
> (D) 25
>
>
> *Important - *This email and any attachments may be confidential. If 
> received in error, please contact us and delete all copies. Before 
> opening or using attachments check them for viruses and defects. 
> Regardless of any loss, damage or consequence, whether caused by the 
> negligence of the sender or not, resulting directly or indirectly from 
> the use of any attached files our liability is limited to resupplying 
> any affected attachments. Any representations or opinions expressed 
> are those of the individual sender, and not necessarily those of the 
> Department of Education and Early Childhood Development.
>
>
> _______________________________________________
> http://www.edulists.com.au - FAQ, Subscribe, Unsubscribe
> IT Software Development Mailing List kindly supported by
> http://www.vcaa.vic.edu.au - Victorian Curriculum and Assessment Authority and
> http://www.vcaa.vic.edu.au/vce/studies/infotech/softwaredevel3-4.html
> http://www.vitta.org.au  - VITTA Victorian Information Technology Teachers Association Inc

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.edulists.com.au/pipermail/sofdev/attachments/20110525/0f9884d7/attachment-0001.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: DeskCheck.xlsx
Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
Size: 11450 bytes
Desc: not available
Url : http://www.edulists.com.au/pipermail/sofdev/attachments/20110525/0f9884d7/DeskCheck-0001.xlsx 


More information about the sofdev mailing list