A new search algorithm by me....is it good????

here is d doc to my ALGO plzz check and tell me weder it is effecient or not ;-)... d article is still incomplete... i m working on it nd even d prog has a bit bug in it... ill fix it vry soon.... i jst wanted to get d ALGO chkd by sm experts out here :-) https://docs.google.com/document/d/1.../edit?hl=en_US

Re: A new search algorithm by me....is it good????

Quote:

Originally Posted by

**drakula941** here is d doc to my ALGO plzz check and tell me weder it is effecient or not ;-)... d article is still incomplete... i m working on it nd even d prog has a bit bug in it... ill fix it vry soon.... i jst wanted to get d ALGO chkd by sm experts out here :-)

https://docs.google.com/document/d/1.../edit?hl=en_US

I'm sorry for saying so, but it is crap; every comparison takes one step so in total your algorithm takes O(n) steps to complete; your conclusion is wrong, otherwise it would be better to divide a list with n elements in n parts and, according to your reasoning, the searching would take O(1) steps.

kind regards,

Jos

Re: A new search algorithm by me....is it good????

but is it not better den linear search??

Re: A new search algorithm by me....is it good????

thnx for correcting me :-).... cn u do d proper analysis of d code for me??? plzzz? :-)

Re: A new search algorithm by me....is it good????

I wouldn't expect anything earth-shaking from somebody too lazy to spell words in full. Recommended reading

db

Re: A new search algorithm by me....is it good????

No. it s nt btr thn a lnr srch

Re: A new search algorithm by me....is it good????

Can any one provide proper reasons?? why the algorithm is not better than linear search??

Re: A new search algorithm by me....is it good????

Quote:

Originally Posted by

**drakula941** Can any one provide proper reasons?? why the algorithm is not better than linear search??

For an unordered sequence your algorithm searches O(n) elements where n is the number of entries in the list; a linear search does the same, only in a more simple order.

kind regards,

Jos

Re: A new search algorithm by me....is it good????

but the number of iterations taken by linear search is more than that of mine....

Re: A new search algorithm by me....is it good????

Quote:

Originally Posted by

**drakula941** but the number of iterations taken by linear search is more than that of mine....

No it isn't; you are counting four search operations as one; that is incorrect. My counter example again: if a sequence contains n elements, break it up in n parts; each part takes O(1) search operations, so dividing by n yields a better search algorithm (not!)

kind regards,

Jos

Re: A new search algorithm by me....is it good????

Can multi threading help in this case ???? like if i use dat den all the comparisons would be done at the same time ryt??please pardon me if my judgments are wrong.I am no expert yet but have a lot of interest and passion for coding.Its not even been a year since when i have learned java.... SO please do not get bugged if i ask or say something unrealistic ;-)

Re: A new search algorithm by me....is it good????

bdw sir can u giv me a situation where linear search would perform better than this???

Re: A new search algorithm by me....is it good????

As Jos said, it's still O(n), say the element to be searched for is at arr.length/4, you will have to do n comparisons. All this does is make 4 comparisons at each step.

If this really yielded better results, why stop at divisions of 4? Why not 8, 16, 32, etc.?

Re: A new search algorithm by me....is it good????

if i use thread over here wouldn't all 4 comparison be done at the same step???and would doing that help?? :-)

Re: A new search algorithm by me....is it good????

and the division sunde887 u spoke of is absolutely correct i thought of it but that can be applicable when the number list is huge.... but don you think by this code the probability of searching an element increases??? just the probability not speed!!!! :-)