Machine-translated by Google. Questions are authored in English.
Top

Discussion

A jump table is preferable to a chain of comparisons when the case values are

  • A.sparse and spread across a very wide range
  • B.known only at run time rather than at compile time
  • C.all of them strings rather than integers
  • D.dense and confined to a narrow range

Answer: D

A table costs one entry per value in the range, so a sparse set wastes space. Compilers commonly choose between the two strategies by measuring the density of the labels. A hybrid using a table for dense regions and comparisons elsewhere is also common.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.