Basic UF
// Naive implementation of findstatic int find(int parent[], int i) {
if (parent[i] == -1) return i;
return find(parent, parent[i]);
}// Naive implementation of union()static void Union(int parent[], int x, int y) {
int xset = find(parent, x);
int yset = find(parent, y);
parent[xset] = yset;
}
Compression
public int find(int p) {
if (p != parent[p])
parent[p] = find(parent[p]);
return parent[p];public void union(int p, int q) {
if (connected(p, q)) return;
for (int i = 0; i < id.length; i++)
if (id[i] == id[p]) id[i] = id[q];
count--;
}
attribution tracking/marketing
The things that I can think of are
- affiliate marketing/promo code/unique phone number/unique url, to track the source of sales
- measure the sales before and after the ads (increased traffic), better to be same time last year.
- do an online questionnaire or offline selective questionnaire
- store (how long, file type)
- volume/scale (qps, max number)
- functions/purpose/types (extra functions)
- device (mobile/web)
- latency
- leverage cloud
- security/encryption
Client-Side (less ideal)
Debounce and throttle are two similar (but different!) techniques to control how many times we allow a function to be executed over time.
debounce — first time, throttle — last time