AlgoFrames

Trace the XOR walk

Standard · Trace the algorithm · about 6 min

The numbers 3, 10, 5, 25, 2 and 8 are stored as 5-bit paths in a binary trie. Follow the walk that finds the best XOR partner for 5 and answer before each step plays.

Example 1

Input:

{"values":[3,10,5,25,2,8],"x":5}

Output:

28

Constraints

  • The trace uses the input shown.

Learn the idea first: Trie applications: autocomplete, word search, XOR maximum, a visual lesson.

More Trie applications: autocomplete, word search, XOR maximum problems