18.04.2013 Views

The.Algorithm.Design.Manual.Springer-Verlag.1998

The.Algorithm.Design.Manual.Springer-Verlag.1998

The.Algorithm.Design.Manual.Springer-Verlag.1998

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Calendrical Calculations<br />

Next: Job Scheduling Up: Combinatorial Problems Previous: Generating Graphs<br />

Calendrical Calculations<br />

Input description: A particular calendar date d, specified by month, day, and year.<br />

Problem description: Which day of the week did d fall on according to the given calendar system?<br />

Discussion: Many business applications need to perform calendrical calculations. Perhaps we want to<br />

display a calendar of a specified month and year. Maybe we need to compute what day of the week or<br />

year some event occurs, as in figuring out the date on which a 180-day futures contract comes due. <strong>The</strong><br />

importance of correct calendrical calculations is perhaps best revealed by the furor over the ``millennium<br />

bug,'' the crisis in legacy programs that allocate only two digits for storing the year.<br />

More complicated questions arise in international applications, because different nations and ethnic<br />

groups around the world use different calendar systems. Some of these, like the Gregorian calendar used<br />

in most of the world, are based on the sun, while others, like the Hebrew calendar, are lunar calendars.<br />

How would you tell today's date according to the Chinese or Arabic calendar?<br />

<strong>The</strong> algorithms associated with calendrical calculations are different from the other problems in this<br />

book, because calendars are historical objects, not mathematical ones. <strong>The</strong> issues revolve around<br />

specifying the rules of the calendrical system and simply implementing them correctly, rather than<br />

file:///E|/BOOK/BOOK4/NODE155.HTM (1 of 3) [19/1/2003 1:30:49]

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!