Page 185 -
P. 185

need a new data structure


           Associate the name with the score


           Using two arrays just won’t cut it. You need some other data structure to hold
           your data in such a way that the association between the surfers’ name and their
           score is maintained.


                    9.12            Zack

       Here's the   8.65            Stacey
        array of    8.45            Juan
        sorted      8.31            Joseph        ...and here's
        scores...                                 the array
                    8.05            Johnny        of sorted
                                                  names.
                    7.81            Aideen                                        Names
                                                                    Scores
                    7.21            Aaron
                                                                    8.65           Johnny           Many rows

                                                                     9.12          Juan             of data
                                                                                   Joseph
                                                                     8.45          Stacey
                      But the scores no longer   What you need is    7.81
                       match the names!       something that          8.05          Aideen
                                               looks like this.       7.21          Zack

                                                                      8.31          Aaron




                                                                                        Exactly two
          You need a different data structure. But which one?                            columns of
                                                                                         matched data







                                Data Structure A standard method of organizing a
                                 collection of data items in your computer's memory.

                                    You've already met one of the classic data structures:
                                      the array.





           150    Chapter 5
   180   181   182   183   184   185   186   187   188   189   190