Message from JavaScript discussions
May 2017
— That way you only ever search a portion of the set, and can ignore other parts because they will never contain the input
On on a has
check for "Dog", we see all unique characters exist in the set, so we traverse to D
, then 3
within D
, and read the contents deductively without comparing the string until we need to
— If we hit 2
and have not found "Dog" yet, we can deduce it is definitely not in the set and abandon the search. all this is for a string specific system so it might not work as well for integers etc... the skip list is still inear but you can jump around it past areas you know will definitely not contain the value, and areas you think might contain the value. so for a linear search of a value, you search only as many values of the set which match the length of the value and other datapoints.
— Coding this now, going very well, I call it an Incremental Probabilistic Inference set
— Oooh
— Made this little doodad, lets us check if all the unique characters of a string exist in the uniques list
—
// Checks if all elements of searchArray exist in targetArray
function includesAll (targetArray, searchArray) {
assert(Array.isArray(targetArray), "Parameter 1 must be an Array.", TypeError);
assert(Array.isArray(searchArray), "Parameter 2 must be an Array.", TypeError);
var uniqueMatches = [];
for (character in searchArray) {
if (!uniqueMatches.includes(character) && targetArray.includes(character)) {
uniqueMatches.push(character);
}
}
return uniqueMatches.length >= searchArray.length;
}
— That check above never runs if these don't pass:
// Deduce if the String is definitely not in the Set from basic data.
if (charArray.length !== 0
&& uniquesLength !== 0
&& listLength !== 0
&& list.hasOwnProperty(charArray[0])
&& list[charArray[0]].hasOwnProperty([charArray.length])
) {
— For "Hello", it checks for this type of path in the set:
{
H: {
5: {
// Word may exist in here
}
}
}
— So as you can probably tell, construction of the set dictates where in the set we conduct the search
— Of course if you have a set with only words which start with H, and are of all the same length, it will be only as effective as a linear search on a flat array
— But for diverse datasets, this will improve search efficiency massively