[Year 12 SofDev] DLTV Exam 1

ATKINSON-BUCK, Damien Damien.ATKINSON-BUCK at ivanhoe.com.au
Wed Oct 8 17:50:58 EST 2014


Hi folks,
            I'm just going through the DLTV Exam and can't quite figure the answer to the algorithm question 12 below.
[cid:image002.png at 01CFE31F.B9E3A930]
[cid:image003.png at 01CFE31F.B9E3A930]

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>

[cid:image001.jpg at 01CFE31E.B9F61530]
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.edulists.com.au/pipermail/sofdev/attachments/20141008/8ea423e7/attachment-0001.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.jpg
Type: image/jpeg
Size: 22355 bytes
Desc: image001.jpg
Url : http://www.edulists.com.au/pipermail/sofdev/attachments/20141008/8ea423e7/image001-0001.jpg 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image002.png
Type: image/png
Size: 56766 bytes
Desc: image002.png
Url : http://www.edulists.com.au/pipermail/sofdev/attachments/20141008/8ea423e7/image002-0001.png 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image003.png
Type: image/png
Size: 46976 bytes
Desc: image003.png
Url : http://www.edulists.com.au/pipermail/sofdev/attachments/20141008/8ea423e7/image003-0001.png 


More information about the sofdev mailing list