Special

Clearance Sale!

We've been publishing for over five years now and it's time to clear out our inventory of back issues, so we're slashing prices!

RBD Magazines

Check out this amazing clearance sale of all our past issues. Missing some issues? This is a great time to complete your RBD collection. Save up to 40% off the regular price of our printed back issue packages. These prices are only good until the end of the year May 2008 and supplies are limited, so place your order today.

Article Preview


Buy Now

Print:
PDF:

Algorithms

Memoizing

How to Take Good Notes

Issue: 1.5 (April/May 2003)
Author: Matt Neuburg
Author Bio: Matt Neuburg is the author of REALbasic: The Definitive Guide, and a member of the editorial board of REALbasic Developer.
Article Description: No description available.
Article Length (in bytes): 13,238
Starting Page Number: 34
RBD Number: 1517
Resource File(s):

Download Icon 1517.sit Updated: Friday, October 17, 2003 at 12:20 PM

Related Link(s): None
Known Limitations: None

Excerpt of article text...

The term "memoizing" is not a misspelling of "memorizing," but the two notions are related. Memoizing is a technique that can come in handy in programming situations where you're performing a calculation that has input, and the same input always yields the same result. The motivation for memoizing arises when the calculation is lengthy and is likely to be performed on the same input more than once. Memoizing itself is a cross between simply performing the calculation, on the one hand, and looking up the answer in a table, on the other.

Perhaps before going any further I should pause to point out that a lookup table is itself an important programming technique that is often neglected by beginners -- perhaps because it seems too easy, or too obvious. For example, suppose you had to implement REALbasic's Hex function, which translates a decimal integer to a hex string. What this really boils down to is translating a value between 0 and 15 into a hex digit, so let's concentrate on that. Clearly there are two cases. If the value is between 0 and 9, we can use it as an offset from the ascii value of the character "0". If it's between 10 and 15, we can subtract 10 and use the result as an offset from the ascii value of the character "A".

...End of Excerpt. Please purchase the magazine to read the full article.

Article copyrighted by REALbasic Developer magazine. All rights reserved.


 


|

 


Weblog Commenting and Trackback by HaloScan.com