Bailey chapter 12 on binary trees, especially sections
3, 4 and 6
Bailey chapter 14 on binary search trees, sections 1-4
It will probably be online, on sakai. Stay tuned!
The study guide is on Sakai. Answers will be posted at the end of this week.
You can bring up to three pages (sides) of your own printed or handwritten notes. You will also receive a copy of StrList.java, which includes examples of basic Java constructions.
Related question: why is insertion sort faster than selection sort?
How fast is quicksort? If you divide an interval in half, at random, what is the expected value of the smaller and larger parts?
1337 approach: bucketize on the last digit, concatenate, bucketize on second-to-last digit, concatenate, bucketize on the first digit (third-to-last digit)
Trees
binary trees
binary search trees
insertion and search
traversal
tree-based dictionaries
in-class lab 1
Install expressionsij.zip
and implement exponentiation
New grammar:
/* Grammar:
expr ::= term { addop term }
term ::= efactor { mulop efactor }
efactor ::= factor [ '^' factor ]
factor ::= number | '(' expr ')'
/* */
Changes: modify termeval() so as to call efactorEval(); add efactorEval():
result = factoreval();
if (t.equals(theToken, "^") {
theToken = t.token();
long res2 =
factorEval();
result =
power(result, res2);
}
private long power(long num, long exp)
{ // this is actually C#. Can you tell?
long prod = 1;
for (int i=0; i<exp; i++) prod *=
num;
return prod;
}