Software Design and Development

Home > Software Design and Development > Core > Software Development Cycle > Standard Algorithms: Arrays and strings

Answers

Standard array and string manipulation algorithms used in software solutions

Activity: Find maximum or minimum value in an array

  1. Trace table FINDMAX

    highindex

    index

    element

    maxval

    comments

    13

    1

    56

    56

    initialisation and set

    priming values

    13

    2

    63

    63

    read next, swap maxval

    13

    3

    75

    75

    read next, swap maxval

    13

    4

    12

    75

    read next, no swap

    13

    5

    54

    75

    read next, no swap

    13

    6

    60

    75

    read next, no swap

    13

    7

    69

    75

    read next, no swap

    13

    8

    47

    75

    read next, no swap

    13

    9

    55

    75

    read next, no swap

    13

    10

    57

    75

    read next, no swap

    13

    11

    61

    75

    read next, no swap

    13

    12

    78

    78

    read next, swap maxval

    13

    13

    51

    78

    read next, no swap













  2. To report on more than one occurrence of the target value you would need to create an array to return all values found rather than a single variable.
Back to Standard array manipulation algorithms used in software solutions

Neals logo | Copyright | Disclaimer | Contact Us | Help