I understand what a binary search algorithm is, but am wondering how that could be implemented on an array in Actionscript (if at all) without using methods that would defeating the purpose of a binary search (speed). Anyone have experience in this area?
So for example, if you have a list like this: ["apple", "orange", "banana", "pear", "cherry", "pineapple", "kiwi", "peach"] Then to do a binary search for say, "pineapple", as I understand binary searching, you would first split the list in the middle (between "pear" and "cherry") and determine if "pineapple" was in that list - if not, search the other half and so on until you find "pineapple". The part I'm not sure how to implement in a binary way is the part to ask the question, "is 'pineapple' in the first list (apple, orange, banana, pear)?" well, to figure that out, in Actionscript, I know of no other way but to either 1) loop through that first list item by item and see if you locate it - if you don't - then search the second list. Which defeats the purpose of a binary search - or 2) to use something like array.indexOf() - which is a lookup itself, and not a binary search - if you were to use that, you've already completed your search before you even get started Either way, you're defeating the purpose of a binary search. . You'd obviously use a recursive function to do a binary search, which I can write, but not sure exactly what that would look like. Jason Merrill Bank of America Global Learning Learning & Performance Solutions Join the Bank of America Flash Platform Community and visit our Instructional Technology Design Blog (note: these are for Bank of America employees only) _______________________________________________ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders