2 Replies - 4369 Views - Last Post: 03 November 2008 - 09:25 PM Rate Topic: -----

#1 sethikamal21  Icon User is offline

  • New D.I.C Head

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

Look up table

Post icon  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  Icon User is offline

  • Programming Theoretician
  • member icon

Reputation: 4438
  • View blog
  • Posts: 12,308
  • 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'." :snap:
Was This Post Helpful? 0
  • +
  • -

#3 sethikamal21  Icon User is offline

  • New D.I.C Head

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

Re: Look up table

Posted 03 November 2008 - 09:25 PM

View Postsethikamal21, 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