Summary: CS4700 Homework #6
Note, these exercises may be done in groups of one, two, or three.
1) In a switch statement, would a standard jump table be an appropriate implementation
for the following distribution of case constants? If not, explain an alternative you
a) Twenty cases close together in value (say a range of 50)
b) A thousand cases close together in value (say a range of 1050)
c) Five cases over a wide range of values (say a range of 1000).
d) A thousand cases over a wide range of values (say a range of 1,000,000).
2) Order of evaluation. While precedence and association controls the parse tree that is
formed, the order of evaluation within the tree might not be specified by the language
design. If there are no side-effects, the order of expression evaluation doesn't matter,
but with side effects, the results are different depending on the expression evaluation
order. What possible values for sum could result?
function Doit( var K: integer) : integer // K is passed by reference
i := 5;