Log of CIS 068 Section 2: Data Structures & Algorithms in JAVA
Week 1, Monday Aug. 27:
Introduction, overview over course, grading scheme. Slide set #1.
Week 1, Friday Aug. 31:
The first long class. Topic: software engineering. Question: Why not just code it? Examples of software failures,
a glimpse into techniques of software engineering to prevent them. Waterfall model and Unified model as design guidelines.
A short mentioning of UML diagrams and Use Cases to formalize the coding process, to get from a project description to
object design. Slide set #2.
The German word of the week was: Erfrischungskaltgetränk (soda).
Week 2, Monday Sept. 3:
Labour Day.
Week 2, Friday Sept. 7:
We didn't have a mini quiz, since there seemed to be a need for a java review, which takes time. We went through the basic
JAVA functionalities, special emphasis on what's happening in memory while the program is running. Typical questions were:
When are objects created? When are class (=static) fields and methods created/accessible? Why is there only a single instance
of a static field? If you can answer the question how to build a class that tells you each time an object is instantiated how many
objects of this class were created before, you have most probably understood that part. Second part of class we talked about
hierarchies, superclasses, subclasses, downcasting, upcasting, overloading, overriding and (greek word of the week!) polymorphism.
The interesting thing (or the basis for the understanding) of polymorphism was the fact that even if an object is upcasted to a parent-class, it
still keeps its own method implementations. This means, that the sequence: "Child c=new Child(); Parent p=c; p.method1();" calls the method1
implementation of class Child. The typical example for inheritance, overriding and design of a class structure containing these principles
was the Drawable -> Triangle, Rectangle, Circle structure: Drawable contains all common fields and methods, Triangle etc. extend Drawable
and only implement the actual printing routine ("show()").
The German word of the week was: Zündhölzchenschächtelchen (matchbox).
No slides this time.
Week 3, Monday Sept. 10
We implemented the Drawable -> Triangle,Rectangle,Circle life in class.
Week 3, Friday Sept. 14
First: mini quiz #1. Then Graphical user interfaces (slides: GUI). Principle how to set up a graphical output, java swing and all it has to offer.
A little life programming, showing the usage of windows, layouts, and my favourite: the color chooser. No functionality behind the interactive
elements (sliders, buttons) yet. German word of the week: 'Jahresendzeitflügelgestalt'
Week 4, Monday Sept. 17
GUI continued: custom drawing. The Graphics class, the JPanel class, the paintComponentMethod(Graphics g), circles, rectangles, colors. Life programming:
frames/circles/rectangles/colors. How to extend JPanel to implement your own paintComponent(Graphics g) method. Reminder: SWITCH IN CLASSES: NEXT CLASS IS
ON WEDNESDAY!
Week 4, Wednesday Sept. 19
Event based programming. Differences between event based and sequential approach to programming. See slides: 'events'. Implementation of the event model in Java,
GUI control elements as event sources, registration of listeners to event sources, program 'circles' showed GUI with events. you can find the source of
'circles' in assignment 2. German word of the week: 'Versandkostenpauschale' (shipping flat rate)
Week 5, Monday Sept. 24
We arived at the data structure part of the class. Definition and discussion of big-O, the order of magnitude. Motivation for data structures:
Different tasks in databases (insert, remove, update, retrieve) have different order of magnitude depending on the underlying datastructure.
Week 5, Wednesday Sept. 26
List, list and lists. linked, double linked, with references to start and end and in between. Insertion, deletion, update, retrieval, analysis of
order of magnitude in comparison to an array. The result: arrays are fast (=O(1)) for retrieval, but slow (O(n)) for insertion and deletion.
Lists act exactly the opposite way: they are fast for insertion/deletion (O(1)), and slow for retrieval (O(n)). No slides this time, but two German
words of the week: "Gesundheit" ((good) health) and "Prost" (cheers). For Lists, please read chapter 4 in the textbook. It gives a lot of information
about the Java specific lists though, skip that for now.
Week 6, Monday Oct. 1
We continued with list operations, mentioned array lists and talked about list traversal. We saw a (wrong!) implementation of list traversal in O(n^2),
using a technique that started from the beginning of the list to traverse to each element. Of course list traversal should be done in O(n).
Week 6, Wednesday Oct. 3
First we talked a little longer than expected about the deer-assignment, as well as about mixed topics
concerning lists. We continued to work on lists, functionalities and analysis of the most general list,
the double linked ring list. We implemented a single linked list in JAVA, programming the necessary
classes (MyNode, MyList) and the addFirst() and traverse() methods. Quiz 4, no word of the week !
Wie schade!
Week 7, Monday Oct. 8
Stacks and Recursion. We discussed different implementations of stacks: as a list, as an array, and just
a pointer to memory (for assembly language fans). We saw how a stack overflow can be caused,
if too many elements are added. The transition to recursion was paved by looking into the JVM and its
usage of a stack during method calls. I tried to solve an equation in 'reverse polish notation' and
failed :-) ... but the equation was solved later by the class. thanks.
Part II: we started with recursion. We mentioned that a recursive function always has an
'if - else' construct. We also talked about the performance of recursive functions: surprisingly
a recursive function is usually slower and less memory efficient than iterative functions,
nevertheless they should be used for the sake of readability.
Week 7, Wednesday Oct. 10
Quiz 5. We stayed a little with stacks, concluded all the runtime analysis of lists, to get the transition
to trees. We started about tree terminology (complete, full, ...), implementational details (a node now always has
multiple links, the references to the children). We talked about different ways to traverse a tree,
pre-order, in-order, post-order. We introduced expression trees, which finally clarified the
connection between the standard notation for math. expressions and the reverse polish notation: you get the standard
notation using in-order traversal, RPN is gained by post-order. We translated a RPN expression into standard notation by
building an expression tree and traversing it accordingly.
Week 8, Monday Oct. 15
Binary trees. At first we discussed general binary trees, we then made the transition to Binary Search Trees.
We analysed the order of magnitude for insertion, deletion and finding of elements. Binary trees allow us to find elements
in a time between O(log n) and O(n), depending how BALANCED the tree is.
Week 8, Wednesday Oct. 17
Quiz 6. More about tree traversal, recursive vs. iterative. Preparation for MIDTERM.
Week 9, Monday Oct. 22
We talked mainly about the assignments, in connectin to implementational questions of Data Structures. And since we were short
on German words in the last weeks, we learned the longest word so far: 'Kaffeesahnenäpfchendeckelsammeln'.
Week 9, Wednesday Oct. 14
MIDTERM. Hurray!
Week 10, Monday Oct. 29
HEAPS. Definition, properties (complete, root of each subtree has minimal value), purpose (sorting). Insertion, deletion.
Week 10, Wednesday Oct. 31
Quiz 7. Heaps continued. Implementation as ARRAY. We analysed a professional implementation and saw that it did exactly what we learned,
which should fill either us or them with pride. We also went through the steps of deletion and insertion again to see the single stages of building
and decomposition of a heap.