title: Variable byte encoding - Information Retrieval
body: <p><strong>Question:</strong></p>
  
  <p>What is the largest gap that can be encoded in 2 bytes using the variable-
  byte encoding ?</p>
  
  <p><strong>Answer:</strong></p>
  
  <p>With 2 bytes, we use 2 continuation bits, and 14 bits are available for gap encoding (2^0 to 2^13). Hence, the largest gap that can be encoded is 2^14 − 1 = 16383 (when all 14 bits are set to 1).</p>
  
  <p><strong>I need to do the same question as above but for 3 bytes. Below is my answer but I am not sure if it is correct. Could somebody let me know if I am doing it correctly? thanks</strong></p>
  
  <p><strong>Question:</strong></p>
  
  <p>What is the largest gap that can be encoded in 3 bytes using the variable-
  byte encoding ?</p>
  
  <p><strong>My Answer:</strong></p>
  
  <p>With 3 bytes, we use 3 continuation bits, and 21 bits are available for gap encoding (2^0 to 2^20). Hence, the largest gap that can be encoded is 2^21 − 1 = 2097151 (when all 21 bits are set to 1).</p>