See submission instructions below: one to a special dropbox, and most to the regular dropbox.
The following formulas for series sums may be helpful:
[Numbers in brackets] are problem numbers from the third edition of the Weiss textbook.
The ACM's Code of Ethics states in section 1.5: Respect the work required to produce new ideas, inventions, creative works, and computing artifacts
If you prefer, you may select another section of the ACM Code of Ethics as the basis for your essay. If you do this, be sure to indicate which section you chose to elaborate.
Grading: If no sys argument, -3. If argument only includes 1 reason why ethical/unethical, -1. If only give 2 examples, -1. If only give 1 example, -3. If examples not developed, -2.
You will submit the following to the WA3 dropbox:
(8 points) Consider the code:
for( int i = 1, i <= n; i++ ) { for( int j = 1; j <= i * i; j++ ) { if( j % i == 0) { for( int k = 0; k < j; k++ ) { sum++; } } } }
The condition on the innermost loop can cause you to overestimate big-Theta the runtime you would get it
you ignored it.
This problem is more complex than previous
problems of this type. As with our analysis of the cubic
algorithm for MCSS in class, you should first derive a (closed-form,
no-summation notation) formula for the exact number of times that the
sum++
statement executes. Be sure
to explain what you are doing, not just write equations. You should see a pattern that will let you use
a summation. Use your derived formula to state a big-Theta estimate; you can use the usual
shortcut of dropping lower-order terms and constant factors only at
this last stage.
(7 points) It is useful to have a unique representation
of binary trees that can be written compactly. For simplicity, we
assume that each node of the tree will contain one
Character
. We represent a tree by a pair of strings, which
I call chars
and children
.
The chars
is a pre-order
listing of the contents of the nodes. The children
string tells about the children of the
corresponding node from chars as follows:
2 | The node has two children. |
0 | The node has no children. |
L | The node only has a left child. |
R | The node only has a right child. |
For example:
chars = "ELSPIPYR"; children = "220200L0";
represents the example "SLIPPERY" tree in our term
project.
chars = "FBADCEGIH"; children = "220200RL0";
represents the tree in this wikipedia page.
What are the values of chars
and children
for the tree below?
For a different tree we have:
chars = "THEQUICKBROWN";
children = "2R220002R0RL0";
Show the order of the nodes in an in-order traversal of the tree.
(7 points) Hint: use the given info to draw the tree!
THEQUICKLAZYFOX
is the
pre-order traversal of a tree (one character per node).
QIUCEHLAZKFYTXO
is the
in-order traversal of the same tree.
What is the order of the nodes in the level-order traversal of this tree?