QUESTIONS LAST TIME: - SiteRiter turn-in details, Hash tables, Collision handling TODAY: - On-time quiz: Memory and pointer diagrams - Design discussion: SiteRiter - More hashing; amortized O(1) PROJECT 1 ALL DONE! PROJECT BREAK THIS WEEK! DO EVERYTHING ELSE! It's On The Internet So It Must Be True: RESEARCHERS SAY COINS ARE OBSOLETE; USE LOGS INSTEAD http://lunagameserve.com:8000/0x5b65d312 ON-TIME QUIZ POST-MORTEM 1. (2 points) Draw a 'memory and pointers' diagram as of the point marked '/* HERE */' in the following program. Omit 'args'. public class Test { public static void main(String[] args) { int x1 = 3; x1 Integer x2 = x1; +-----+ Integer x3 = x2; | | /* HERE */ | 3 | System.out.println(x1+x2+x3); +-----+ } } x2 +-------+ Integer | | +---------+ x3 | --------->| | +---------+ +-------+ | 3 | | | | | | ----------------------->+---------+ | | +---------+ ON-TIME QUIZ POST-MORTEM 2. (3 points) Draw a 'memory and pointers' diagram as of the point marked '/* HERE */' in the following program. Omit 'args'. public class Test { t1 int num = 6; +------+ Test(int n) { num = n; } | -----\ public static void main(String[] args) { | | | Test t1 = new Test(4); +------+ | Test t2 = new Test(1); t2 | Test t1 = t2; +------+ | +--------+ /* HERE */ | -----\->| | System.out.println(t1.num+t2.num); | | | 1 | } +------+ | | } +--------+ ON-TIME QUIZ POST-MORTEM 3. (4 points) Draw a 'memory and pointers' diagram as of the point marked '/* HERE */' in the following program. Omit 'args'. public class Test { int a; Test b, c; Test(int d, Test e, Test f) { a = d; b = e; c = f; } public static void main(String[] args) { Test t1 = new Test(7,null,null); t1 Test Test t2 = new Test(3,null,t1); +--------+ +------+ t1.b = t2; | | | 7 | t1 = t2.c.b; | | | |------| /* HERE */ +-----|--+ /----- | System.out.println(t1.a+" "+t2.a); | | |------| } t2 Test v | |null | } +----+ +------+<---/ | | | ---->| 3 | +------+ +----+ |------| ^ |null | | |------| | | ------------/ +------+ SITERITER DISCUSSION - What was harder/slower than you expected? - What was easier/faster than you expected? - What was the first bit of code you wrote? - What was the last bit of code you threw out? SITERITER DISCUSSION - What was harder/slower than you expected? - What was easier/faster than you expected? - What was the first bit of code you wrote? - What was the last bit of code you threw out? - Design issues: = Lexing, reading, marking, tokens = Parsing strategy = Symbol table design SITERITER DISCUSSION - What was harder/slower than you expected? - What was easier/faster than you expected? - What was the first bit of code you wrote? - What was the last bit of code you threw out? - Design issues: = Lexing, reading, marking, tokens = Parsing strategy = Symbol table design Dave's choices: = Lexing: YES, reading: BY CHAR, marking: YES, tokens: String = Parsing strategy: Top down parser = Symbol table design: Map Symbol has ArrayList Sequence has ArrayList for tokens SITERITER DISCUSSION - What was harder/slower than you expected? - What was easier/faster than you expected? - What was the first bit of code you wrote? - What was the last bit of code you threw out? - Design issues: = Lexing, reading, marking, tokens = Parsing strategy = Symbol table design Dave's choices: = Lexing: YES, reading: BY CHAR, marking: YES, tokens: String = Parsing strategy: Top down parser = Symbol table design: Map Symbol has ArrayList Sequence has ArrayList for tokens [ Eclipse code peeks ]