Understanding the Need to Sort and Search
Determining the Need for Structure
Structure is an essential element in making algorithms work. As shown in the
binary search example in Chapter 5, implementing an algorithm using structured
data is much easier than trying to figure out how to interpret the data in code. For
example, the binary search example relies on having the data in sorted order. Try-
ing to perform the required comparisons with unsorted data would require a lot
more effort and potentially prove impossible to implement. With all this in mind,
you need to consider the structural requirements for the data you use with your
algorithms, as discussed in the following sections.
Do'stlaringiz bilan baham: |