[Year 12 SofDev] DLTV Exam 1

ATKINSON-BUCK, Damien Damien.ATKINSON-BUCK at ivanhoe.com.au
Wed Oct 8 23:20:14 EST 2014


Thanks Alan/James

Damien Atkinson-Buck
Head of Learning Area: Technology/Arts

[cid:image002.jpg at 01CFE34E.60D611F0]

p: +61 3 9490 3848

e: damien.atkinson-buck at ivanhoe.com.au<mailto:damien.atkinson-buck at ivanhoe.com.au>

f: +61 3 9490 3490

w: www.ivanhoe.com.au<http://www.ivanhoe.com.au/>


w: www.ivanhoe100.com.au<http://www.ivanhoe100.com.au/>



From: alan whittaker [mailto:awhittaker at netspace.net.au]
Sent: Wednesday, 8 October 2014 10:08 PM
To: Year 12 Software Development Teachers' Mailing List
Subject: Re: [Year 12 SofDev] DLTV Exam 1


Hello there,

I think the issue is the Mod keyword in your VB code (somewhere around line 10). The pseudocode does state a "Mod()" function but I don't think it should be there (in other words I don't know what it is meant to do).
Mod gives you the remainder when the left number is divided by the one on the right,
therefore, no matter the values of low and high, this will always give you a value of 0 or 1 (when dividing by 2), which would explain your infinite loop.

ie: (1 + 999) Mod 2 = 1000 Mod 2
                                   = 0
            as the remainder when 1000 is divided by 2 is 0.

Given that Mod can only give you two values, your loop will never end as StudentNo(0) = 1 and StudentNo(1) = 125, neither of which are the searchnum.
Instead of finding the modulus of low + high, just dividing it by 2 will give the middle number between low and high, and I think will fix the loop.


Hope this helps
James son of an aging, once-an-IT-teacher, Alan Whittaker (Kept him off the games for a while)


On 08/10/2014, at 5:50 PM, ATKINSON-BUCK, Damien wrote:


Hi folks,
            I'm just going through the DLTV Exam and can't quite figure the answer to the algorithm question 12 below.
<image002.png>
<image003.png>

My desk produces,
Pass

Middle

Low

High

Result

StudentNo(Middle)

1

0

1

999

False

1

2

1

0

999

False

125

3

0

1

999

False

1

4

1

0

999

False

125

AND SO ON


I've tried it as vb code below and ended in an infinite loop. Am I missing something blatantly obvious here or can anyone see the fix for this?

Module Module1
    Dim StudentNo() As Integer = {1, 125, 250, 375, 500, 625, 750, 875, 999}

    Sub Main()
        Dim low As Integer = 1
        Dim high As Integer = 999
        Dim result As Boolean = False
        Dim searchnum As Integer = 375

        Do While low <= high And result = False
            Dim middle As Integer = (low + high) Mod 2
            If StudentNo(middle) = searchnum Then
                result = True
                Dim myMessage As String = "Low " & low & ", High " & high & ", Mid " & middle
                MsgBox(myMessage, vbOK, "DONE")
            End If
            If StudentNo(middle) > searchnum Then
                high = middle
            Else
                low = middle
            End If
        Loop
    End Sub

End Module




Damien Atkinson-Buck
Head of Learning Area: Technology/Arts
p: +61 3 9490 3848

e: damien.atkinson-buck at ivanhoe.com.au<mailto:damien.atkinson-buck at ivanhoe.com.au>



f: +61 3 9490 3490

w: www.ivanhoe.com.au<http://www.ivanhoe.com.au/>

w: www.ivanhoe100.com.au<http://www.ivanhoe100.com.au/>

<image001.jpg>
Please consider the environment before printing this e-mail.




Privacy, Virus and Copyright Warning

The information contained in this electronic message (e-mail), and any files transmitted with it:

* is intended for the named recipients only. If you have received this in error, please advise the sender and delete it and any copies immediately;
* Any personal information in this email must be used in accordance with the Privacy Act 1988 and this always applies even if it has been sent to you in error.
* represents the views of the sender and does not necessarily represent the views or formal advice of Ivanhoe Grammar School;
* may be subject to Copyright, so no further use should be made of it without the author's permission.

The School does not represent or warrant that the email or any files attached do not contain errors or are free from computer viruses or other defects nor does it accept responsibility for any loss or damage resulting directly or indirectly from the use of the email or any attached files. _______________________________________________
http://www.edulists.com.au<http://www.edulists.com.au/> - FAQ, Subscribe, Unsubscribe
IT Software Development Mailing List kindly supported by
http://www.vcaa.vic.edu.au<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<http://www.vitta.org.au/>  - VITTA Victorian Information Technology Teachers Association Inc
http://www.swinburne.edu.au/ict/schools - Swinburne University





Privacy, Virus and Copyright Warning

The information contained in this electronic message (e-mail), and any files transmitted with it:

* is intended for the named recipients only. If you have received this in error, please advise the sender and delete it and any copies immediately;
* Any personal information in this email must be used in accordance with the Privacy Act 1988 and this always applies even if it has been sent to you in error.
* represents the views of the sender and does not necessarily represent the views or formal advice of Ivanhoe Grammar School;
* may be subject to Copyright, so no further use should be made of it without the author's permission.

The School does not represent or warrant that the email or any files attached do not contain errors or are free from computer viruses or other defects nor does it accept responsibility for any loss or damage resulting directly or indirectly from the use of the email or any attached files.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.edulists.com.au/pipermail/sofdev/attachments/20141008/b18030e0/attachment-0001.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 1024 bytes
Desc: image001.png
Url : http://www.edulists.com.au/pipermail/sofdev/attachments/20141008/b18030e0/image001-0001.png 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image002.jpg
Type: image/jpeg
Size: 5753 bytes
Desc: image002.jpg
Url : http://www.edulists.com.au/pipermail/sofdev/attachments/20141008/b18030e0/image002-0001.jpg 


More information about the sofdev mailing list