Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jun 14th, 2005, 12:57 PM   #11
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
No question about it -- it can't be universally effective.
Quote:
Originally Posted by DaWei
If one has a data set that can be described (or closely approximated) by a function, then an interpolative search using that function should be very effective, since the initial "guess" zeroes in rapidly regardless of where the "needle" is in the "haystack."
I can only imagine it being useful in things like, for instance, statistical analysis of quality control data. Hell, the fall-off from effective to ineffective could serve as a measure of degree of linearity.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Jun 14th, 2005, 5:23 PM   #12
jim mcnamara
Hobbyist Programmer
 
Join Date: Jun 2005
Location: New Mexico
Posts: 228
Rep Power: 4 jim mcnamara is on a distinguished road
As a quick note:

There are other random number functions out there for unix like drand48().

Writing a decent PRNG is hard and rand() usually is not a decent PRNG for most implementations. They usually copy Knuth -- which is fine for playing simple games. There is a LOT of stuff out there on google about PRNG's. (pseudo-random number generator)

rand()*rand() may not be what you want in other words.
jim mcnamara is offline   Reply With Quote
Old Jun 14th, 2005, 5:44 PM   #13
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Well, I wasn't looking for random, just something not quite linear. Sorting kinda plays hell with ultimate randomness. Hi, Jim, good to see ya .
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Jun 14th, 2005, 11:40 PM   #14
EverLearning
Hobbyist Programmer
 
EverLearning's Avatar
 
Join Date: May 2005
Location: Indiana
Posts: 130
Rep Power: 4 EverLearning is on a distinguished road
Wooooow.... wish i had more spare time for this ...

I also found a paper on precise efficiency analysis of interpolation search (hope to get to reading that soon).

This has been quite interesting...

I know that searches/sorts are chosen depending on data but did anyone of you ever used this search in reality (work place)? just out of curiosity... or would you go with the "safest" bet? like binary search or some other all-time favorite.
__________________
got math? yumm...

"All men by nature desire to know" -Aristotle, Metaphysics
EverLearning is offline   Reply With Quote
Old Jun 15th, 2005, 3:33 AM   #15
nnxion
Programming Guru
 
nnxion's Avatar
 
Join Date: Jun 2005
Location: elemental plane
Posts: 1,429
Rep Power: 5 nnxion is on a distinguished road
For sorting heap-sort is supposed to be really good.
__________________
"Employ your time in improving yourself by other men's writings, so that you shall gain easily what others have labored hard for."
-- Socrates
nnxion is offline   Reply With Quote
Old Jun 15th, 2005, 6:47 AM   #16
Ancient Dragon
PFO God In Training
 
Ancient Dragon's Avatar
 
Join Date: Jun 2005
Location: near St Louis, MO. (USA)
Posts: 516
Rep Power: 4 Ancient Dragon is on a distinguished road
Quote:
Originally Posted by EverLearning
I know that searches/sorts are chosen depending on data but did anyone of you ever used this search in reality (work place)? just out of curiosity
No. I only use binary search on sorted data sets. interpolation search is only useful when you have a dataset that rarely, if ever, changes.
Ancient Dragon is offline   Reply With Quote
Old Jun 15th, 2005, 8:09 AM   #17
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
I would use binary search. Bear in mind that the number of elements affects the efficiency opposite to the way it affects a sort, too. It's better to combine multiple sets and search the large set than it is to search the smaller sets.

For grins, you could fill the array with values generated by an exponential function and watch the linear interpolation search go to hell in a handbasket. An exponential interpolation would do well though. An example of an interpolative search is the way most people look up a word in the dictionary. The data are amenable, so that's what we use.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Jun 15th, 2005, 8:35 AM   #18
Ancient Dragon
PFO God In Training
 
Ancient Dragon's Avatar
 
Join Date: Jun 2005
Location: near St Louis, MO. (USA)
Posts: 516
Rep Power: 4 Ancient Dragon is on a distinguished road
Quote:
Originally Posted by DaWei
For grins, you could fill the array with values generated by an exponential function and watch the linear interpolation search go to hell in a handbasket. .
That's what happed in my post #10.
Ancient Dragon is offline   Reply With Quote
Old Jun 15th, 2005, 9:32 AM   #19
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
An exponential interpolation would work well on an exponential distribution, just as linear interpolation works well on a linear distribution. I leave it as an exercise for the reader (I just looove to say that!) to show that a random interpolation does NOT work well on a random distribution. That's why we use binary searches .
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Jun 15th, 2005, 10:04 AM   #20
jim mcnamara
Hobbyist Programmer
 
Join Date: Jun 2005
Location: New Mexico
Posts: 228
Rep Power: 4 jim mcnamara is on a distinguished road
In the real world I use a generalized sort - PNMqsort() which is faster on most of the datasets we have. It's still a quiksort, it just swaps pointers instead of data.
It's based on the glibc2.3.3 (GNU) version of qsort.

For large filesorts (>4GB) we use commercial sort routines (SyncSort) and a HPUX box with a LOT of free disk space on /var/adm. These routines mmap the input, output, and tmp files, so they use a lot of memory, and what doesn't fit in memory slops over into the tmp file.
jim mcnamara is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 7:56 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC