Tilted Forum Project Discussion Community  

Go Back   Tilted Forum Project Discussion Community > Interests > Tilted Technology


 
 
LinkBack Thread Tools
Old 04-30-2005, 07:43 AM   #1 (permalink)
Psycho
 
Location: Cow Country, CT
Optimization search code

I am working on am senior design project and i am having a large problem with my search. My microcontroller takes and input then compares it to a past value and then makes a dession about what to do bease on the past input. seems simple enough... no way... due to round off errors the program is always getting false input. My ? is can someone help me to write a search program that could attempt to find a unkown value in a almost unordered string... something like finding 2 when the numbers are 1 1 3 2 4 3 5 5 4 6 7 8 8 7 9
something like that... i mean not exactly like that... but that is kind of what i am dealing with. if you need anymore info let me know.... thanks in advance
__________________
No, they arnt breasts, they are personalities, because its ok to like a girl for her personalities.
the420star is offline  
Old 05-01-2005, 08:07 AM   #2 (permalink)
Junkie
 
I'm confused by your question. You are trying to find a number in an unordered list right? Just do a simple linear search to find it. It sounds like you are working with floating point numbers though which means rounding errors will ruin your equality. So then use an epislon factor to determine equality.

For instance here is some psuedo code


Code:
int Search(List L, double number)
{
   e=10^-6
   for i=1 to L.length
        if (abs(L[i]-number)<e)
             return i
   return -1
}
where -1 indicates the number is not in the list.

Last edited by Rekna; 05-01-2005 at 08:09 AM..
Rekna is offline  
 

Tags
code, optimization, search


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
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -8. The time now is 09:57 AM.

Tilted Forum Project

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Search Engine Optimization by vBSEO 3.6.0 PL2
© 2002-2012 Tilted Forum Project

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76