← All Exercises
Skip List with Deterministic Levels
advancedjavascript
Background
Skip lists deliver O(log n) expected search with a simple linked structure, powering Redis sorted sets and older MemSQL indexes. A deterministic level rule keeps this exercise reproducible.
Problem
Implement a skip list with maximum level 4. A node level is 1 plus the number of trailing zero bits (capped at 3) in the FNV-1a hash of the key string. Support insert and search, then output the sorted values, the search verdicts, and the count of nodes reachable at each level 0 through 3.
Input
A JSON object {"insert": number[], "find": number[]} with distinct insert values.Output
A JSON object {"sorted": number[], "found": boolean[], "levelCounts": number[]} of length 4.Sample tests
Sample 1
Input: {"insert":[5,2,8,1,9,3],"find":[8,4]}Expected: {"sorted":[1,2,3,5,8,9],"found":[true,false],"levelCounts":[6,4,3,1]}Sample 2
Input: {"insert":[10,20,30],"find":[30]}Expected: {"sorted":[10,20,30],"found":[true],"levelCounts":[3,2,1,0]}Your solution
Learning objective
Understand layered linked lists, splice-point bookkeeping, and level-based search descent.