16b: Course Review
ICS211, Spring 2013
Dr. Zach
(switch view)
Status
- Our last class!
- Quiz 14 posted
- A11 due Fri.
- Tamarin now ready.
- Grader modified this morning: dictionary all lowercase now (though still not alphabetical)
ICS211 Course Catalog Description
Algorithms and their complexity, introduction to software engineering, data structures, searching and sorting algorithms, numerical errors.
Oops: Numerical errors
- Didn't point this this out explicitly
- 2 parts:
- Finite precision of represented numbers (includes round-off errors)
System.out.println(3 / 2); // 1, due to int math
System.out.println(2.0 / 3); // 0.66666... but only so many 6s
System.out.println(0.1 * 0.1); // 0.010000000000000002
//due to binary representation limits: 0.1 == 0b110011001100... x 2e-4
- overflow and underflow
byte b = 127;
b++;
System.out.println(b); // -128 (overflow)
b--;
System.out.println(b); // 127 (underflow)
- Boils down to: finite representations used to represent infinite precision/range
From Syllabus: Course Objectives
Upon successfully completing this course, students will be:
- competent Java programmers
- proficient with common best practices in object-oriented programming, software design, and implementation
- familiar with common abstract data types (such as stacks, queues, lists, and trees)
- familiar with common searching and sorting algorithms
- able to evaluate, choose, customize, and implement the most appropriate algorithm or data structure for a given problem
Java Programming
- Did lots of this
- Started with review of basics: conditionals, loops, methods, objects
- Resources: API, Java Tutorial. (Google, StackOverflow, etc often help too.)
- Tools (mostly in lab): java, javac, jar, javadoc; IDEs, debugger; unix; (junit)
- Java Collections (java.util)
- GUIs (Swing)
- enums, StringBuffer, I/O (streams), binary operators, etc.
Software Engineering and OOP
- Methodology (across models): requirements, design, implement, test (verify/validate), maintain
- OOP principles: abstraction, encapsulation, modularity, reuse, (immutability)
- OOP practicalities: classes, interfaces, inheritance, overriding, polymorphism
Data structures and ADTS
- Data structures: array, linked list of nodes
- circular queue, heap, hash table
- trees (binary, BST, Huffman)
- graph (adjacency matrix, adjacency list)
- ADTs: stack, queue, list, (sorted list), priority queue, deque, set, map, (graph)
Algorithms
- What an algorithm is
- unambiguous sequence of steps that solves a particular problem in finite time
- Recursion and backtracking
- Algorithm analysis - worst-case growth rate (big-O)
- implementation evaluation - benchmarking
- Some particular algorithms
- searching (linear, binary; with trees: DFS, BFS)
- sorting (six variants)
Practical application to problems
- As per our first online discussion: many factors to consider when selecting algorithm
- Analysis: big-O, especially in different contexts (algorithms and data structurs)
- Assignment practice (choosing design/implementation)
After this course
If you have a B or better:
- ICS311 - Algorithms
- ICS212 - Program Structure (C/C++)
If you have a B- or lower:
Advanced Data Structures
- Many variants of what you learned out there
- Different sorts, heaps, etc.
- Trees (as example):
- Self-balancing BST: splay trees, red-black trees, AVL trees
- Tree-like: Skip list
- General trees: B-trees, B+-trees, 2,3-trees, 2,3,4-trees
- Tries (prefix trees)
- etc, etc.
- All variations of what you know: arrays and reference/node-based structures
- More are invented all the time
- Sometimes you'll even invent your own
Final Exam
- Comprehensive
- ~25 to 30% on the hashing, maps, sets, etc.
- About a page or two longer than the others, but same # of points
- Will likely boost your grade (though not a lot)
- Also need an exam average of 70+% to get a B or better.
- So could have a 90% course average and still only get a B-
- If you're sure the final won't help you enough to be worth the time, you can skip it
Job Interview Question #6
How would you implement an LRU cache?
- A cache: temporary storage of data in memory
- Key (filename, URL, or id) maps to data
- Need to be able to access data in constant time
- When cache fills up, need to drop something to make room for new
- Example drop rules:
- LRU: Least recently used
- LFU: Least frequently used
- Should be able to drop in constant time too
My solution:
A map (hashtable) of keys to entry-containing nodes in a doubly-linked list.
On each access, move node to front of the list. LRU is last item in list.
Great example of building a custom ADT!
Job Interview Question #7
Assume you have a max-heap of size n.
How do you find the k largest elements in that heap
with a big-O performance that does not depend on n?
- For example, if we just grabbed the largest element and reheapified k times,
our algorithm would be O(k lg n).
- Can we do it in O(k^2) or even O(k lg k)?
Challenge:
Is it possible to retrieve the k largest element in O(k) time?
Provide either a solution or a convincing proof that it is not possible and I'll give you 15 pts EC on your exam score.
Final Days
- A former LA (Branden) wrote a automated practice exam tool you can use to review
- If haven't yet: eCafe feedback (please)
- Finish A11 and Quiz 14
- Will announce on main site when grading is done
Thank You
- It's been fun!
- (Maybe see you at the final or around campus in the early summer.)