Can anyone tell how to implement Look up table
Look up table
Page 1 of 12 Replies  4206 Views  Last Post: 03 November 2008  09:25 PM
Replies To: Look up table
#2
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'."
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'."
#3
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.
Page 1 of 1
