0

So I am covering succinct trees, and in the lecture, it mentioned that "An n-node tree takes 2n pointers or 2n lg n bits (can be easily reduced to n lg n + O(n) bits). First, question is why 2nlgn bits, and how we can reduce it to nlgn?

kjkjkjkjkj
  • 45
  • 3

1 Answers1

2

They say “pointer” but use that word in a very nonstandard way. What they actually mean is array indexes. Every item has an index from 0 to n-1. If n < 2^k then you need only k bits to store such an index. The other way round, k = ceil(log n), that is the base-2 logarithm of the number of items, rounded up to an integer.

In practice, since items are likely to be many bits, and odd numbers of bits for indexes make your code complicated and slow, you would likely have an 8, 16 or 32 bit index for up to 255, 65,000 or 4 billion items. Or real pointers, usually 64 bit.

gnasher729
  • 32,238
  • 36
  • 56