# Look up table

Page 1 of 1

## 2 Replies - 4632 Views - Last Post: 03 November 2008 - 09:25 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=70180&amp;s=4441f791953ef2a118d0e624f74cc976&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 sethikamal21

• New D.I.C Head

Reputation: 0
• Posts: 3
• Joined: 02-November 08

# Look up table

Posted 02 November 2008 - 10:02 PM

Can anyone tell how to implement Look up table
Is This A Good Question/Topic? 0

## Replies To: Look up table

### #2 Martyr2

• Programming Theoretician

Reputation: 4815
• Posts: 13,079
• Joined: 18-April 07

## Re: Look up table

Posted 02 November 2008 - 10:34 PM

A lookup table is simply an array which stores the answers to a given equation or chart. The values are precalculated so that next time you need to do the calculation, you can save time and instead have a programming language simply access the array and get the answer.

For example, lets square the values of common numbers and in an array that looks like...

Key | Value
-------------
0 : 0
1 : 1
2 : 4
3 : 9
4 : 16

So the value is the square of its index. Now I have a lookup table. Next time I want to calculate the square of 4, I don't have to. I can simply access the array "squares[4]" and it will return "16".

As you can imagine other examples will be more complex than this. The value might be the answer of a long complex equation. So it will save you time to just look it up once it has been calculated once.

Hope that makes sense to you.

"At DIC we be table lookup code ninjas.... let me look up Martyr2.... yup, his value is still 'cool'."
Was This Post Helpful? 0

### #3 sethikamal21

• New D.I.C Head

Reputation: 0
• Posts: 3
• Joined: 02-November 08

## Re: Look up table

Posted 03 November 2008 - 09:25 PM

sethikamal21, on 2 Nov, 2008 - 09:02 PM, said:

Can anyone tell how to implement Look up table

Thanks,
But
my problem is not so simple, I am having key of 320*280 array and the values are again of 320*280 array. Corresponding to each key there is a value. So kindly suggest the solution and proper data structure for this problem.
Was This Post Helpful? 0

Page 1 of 1

 .related ul { list-style-type: circle; font-size: 12px; font-weight: bold; } .related li { margin-bottom: 5px; background-position: left 7px !important; margin-left: -35px; } .related h2 { font-size: 18px; font-weight: bold; } .related a { color: blue; }