O'Reilly logo

Data Structures Using Java by Duncan A. Buell

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

1.1 The Course of This Course 7
with images. Anyone who has seen a video buffered up or played back in a bursty
fashion will recognize the problem.
To counteract the problems with bandwidth, most programs for mobile devices
must make careful use of memory and data structures, freeing up and then reusing
memory space when possible, and delaying execution of certain functions for as
long as possible.
Consider something as simple as a slideshow of photos for a museum tour. If
the program is written to run on mobile devices owned by the museum, the photos
can be downloaded to the devices long in advance and kept in a memory card. If,
however, a museum visitor can use her own smart mobile device, then the program
designer has to consider whether it will be acceptable to users to have to wait 2
or 3 minutes to download the entire collection of images and then display them.
Or should the download be delayed as long as possible, in hopes that the visitor
will linger over photo n long enough to permit photo n + 1 to be downloaded just
before it is needed?
1.1.8 Heuristics
Finally, we recognize that there are times when the best becomes the enemy of
the good. In any given application, how good is good enough? We have already
mentioned that quicksort, to be covered later, is usually the “standard” sorting
method used for practical applications, not because it is theoretically the best
method available (it is not) but because it is a relatively simple method with good
average-case behavior.
Similarly, it is probably unusual for someone to print a new paper copy of an
address list just because one person has been added to the electronic list. More
likely the electronic list is updated and the paper copy is simply annotated with a
handwritten reference. When so many changes to the paper copy have been made
that the paper copy is too messy to be convenient, a new paper copy will be printed.
In truly serious data-intensive applications, the same principle might well apply. If
there is enormous effort involved, for example, in a one-time sort of the entire data
object, then one might plan to maintain the changes as an addendum to the main
object and then incorporate the changes in a block only at intervals, perhaps daily,
weekly, or monthly. For such applications, the heuristics of how to do incremental
updates can be very important.
A heuristic in computer science is a general guideline, based on experience and
an understanding of the problem, that leads to the implementation of specific algo-
rithms or design features in the software meant to solve the problem or provide
the service. Especially when performance is an issue, we usually write programs
whose execution is based on normal, average use. We will include the code to deal
with pathological cases (because we have to cover all possible inputs), but we will

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required