crammy90
Member
- Joined
- Mar 26, 2006
- Messages
- 264
- Gender
- Male
- HSC
- 2008
Hey, I have been looking over my notes and am still struggling with some aspects of coding
ok
in this algorithm it is finding the maximum value in an array through just a linear search
BEGIN FINDMAX
highindex = ARRAYLENGTH(element)
index = 1
maxval = element(index)
WHILE index <= highindex
IF element(index) > maxval
THEN maxval = element(index)
ENDIF
index = index + 1
ENDWHILE
DISPLAY "The maximum element is " maxval
END FINDMAX
</pre><br>I am having trouble understanding what the part in brackets is i.e. element(index)
im sorta guessing that the (index) part is taking the value of the element at index position 1, but what does the "element" part refer to before it?<BR>
And also if the (index) were to be presented as [index], what is the difference?
thanks alot if anyone can help me
ok
in this algorithm it is finding the maximum value in an array through just a linear search
BEGIN FINDMAX
highindex = ARRAYLENGTH(element)
index = 1
maxval = element(index)
WHILE index <= highindex
IF element(index) > maxval
THEN maxval = element(index)
ENDIF
index = index + 1
ENDWHILE
DISPLAY "The maximum element is " maxval
END FINDMAX
</pre><br>I am having trouble understanding what the part in brackets is i.e. element(index)
im sorta guessing that the (index) part is taking the value of the element at index position 1, but what does the "element" part refer to before it?<BR>
And also if the (index) were to be presented as [index], what is the difference?
thanks alot if anyone can help me
Last edited: