Does anybody know of a way to organize a binary search in LibreOffice Calc?
To take a simple example, say I have column A with the numbers 1-16 listed, sorted in ascending order: (1,2,3,...); and column B which lists names of widgets; and I want to find a given widget by searching the numbers in column A. Simple enough: =SEARCH(number;A1:A16;B1:B16). But suppose my list contains 1600 numbers, sorted, and I need the widget name associated with entry 992. 'Search' would have to go through 992 iterations to reach the desired value. A binary search, a la java, would cut that down to maybe 10 iterations. But can that be done?
As nearly as I can tell, each cell in a spreadsheet is fundamentally independent of all the others, and even organizing a binary search "tree" within a group of cells, Calc would want to go through every cell and calculate its value based on whatever formula the given cell contains - even if the cell is extraneous to the search thread.
SO: is a binary search possible?
I have built a binary search tree inside a LibreCalc sheet. Formally, the tree works: visually, I get something like:
where (*) represents cell contents that show the presence of 'hits'. However, this is not really a binary search, because LibreOffice Calc will elaborate all cells - say A, A1, A2 - even though they are not on the search path, which passes through (B)-(B1).