Question: Fast Unsorted Array Search
#1

How could I search a value in an unsorted array, in a fast way ?

I was thinking about using binary tree but I don't know if its possible in an unsorted array.
Any suggestions?
Reply
#2

only a linear search, if the script doesnt know anything about the content.
are there any constraints of the values in the array?
like, is each value unique, is there a min/max limit?
Reply
#3

Quote:
Originally Posted by Babul
Посмотреть сообщение
only a linear search, if the script doesnt know anything about the content.
are there any constraints of the values contained in the array?
like, is each value unique, is there a min/max limit?
Nope, each index stores an ID, and the script doesn't know anything about it.
About limits, no maximum (well 2^31-1 as we can only work with 32-bit variables), minimum would be 1 or 0.

I think that y_bintree can help me here with generating a binary tree for an array, however I have no experience with that library at all, ill search some info in YSI wiki or in the script itself.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)