@hikae/jev-algorithms 0.1.0-rc.0 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -58,22 +58,23 @@ algorithms on the same contract.
58
58
  ## Algorithms
59
59
 
60
60
  Every algorithm states its request cost in terms of `n` items. A request
61
- carries many questions, so "one request" is rarely one comparison.
61
+ carries up to 40 questions, so "one request" is rarely one comparison.
62
62
 
63
63
  ### Sorting and selection
64
64
 
65
65
  | Function | What it does | Requests |
66
66
  | --- | --- | --- |
67
- | `sortByPairwise(client, items, options)` | Total order from pairwise "which ranks higher?" answers | `O(log n)` |
68
- | `sortByPairwiseWith(items, compare)` | Same, with an injected comparator (no client) | `O(log n)` |
69
- | `selectTopK(client, items, k, options)` | Top-k, ordered, via quickselect | `O(log n)` |
70
- | `selectTopKWith(items, k, compare)` | Same, with an injected comparator | `O(log n)` |
67
+ | `sortByPairwise(client, items, options)` | Total order from pairwise "which ranks higher?" answers | `O((n/40) log n)` |
68
+ | `sortByPairwiseWith(items, compare)` | Same, with an injected comparator (no client) | `O((n/40) log n)` |
69
+ | `selectTopK(client, items, k, options)` | Top-k, ordered, via quickselect | `O(n/40 + (k/40) log k)` |
70
+ | `selectTopKWith(items, k, compare)` | Same, with an injected comparator | `O(n/40 + (k/40) log k)` |
71
71
  | `createPairComparator(client, items, options)` | Build the comparator to plug Jev into any sort you own | — |
72
72
 
73
73
  The sort is randomized quicksort whose recursion runs level by level. Nodes on
74
- a level are disjoint, so all their pivot comparisons fit in one request — the
75
- whole order costs `~log n` round trips instead of `n log n`. `selectTopK` skips
76
- the side that cannot contain the k-th item.
74
+ a level are disjoint, so a level's comparisons are batched into `⌈n/40⌉`
75
+ requests at `DEFAULT_MAX_PAIRS_PER_REQUEST` pairs each. The whole order costs
76
+ `O((n/40) log n)` requests instead of `n log n` individual comparisons.
77
+ `selectTopK` skips the side that cannot contain the k-th item.
77
78
 
78
79
  ### Threshold search
79
80
 
@@ -124,7 +125,7 @@ builds each side's preference order with pairwise comparisons first.
124
125
 
125
126
  ## Design notes
126
127
 
127
- - **Batch by default.** Every algorithm packs many questions into one
128
+ - **Batch by default.** Every algorithm packs up to 40 questions into one
128
129
  `evaluate` call and references items through a chunk-local index so a shared
129
130
  item travels once.
130
131
  - **Fail loud, not wrong.** If Jev omits an answer, algorithms throw. They
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hikae/jev-algorithms",
3
- "version": "0.1.0-rc.0",
3
+ "version": "0.1.0",
4
4
  "description": "Runtime-agnostic algorithms built on TypeSafe's Jev structured-evaluation model.",
5
5
  "keywords": [
6
6
  "jev",