 # Lecture 22, Revision 1 Lecture notes Java code – CodeFromLectures folder* Example class sheets – 4 of these plus solutions Extra examples (quicksort) Lab.

## Presentation on theme: "Lecture 22, Revision 1 Lecture notes Java code – CodeFromLectures folder* Example class sheets – 4 of these plus solutions Extra examples (quicksort) Lab."— Presentation transcript:

Lecture 22, Revision 1 Lecture notes Java code – CodeFromLectures folder* Example class sheets – 4 of these plus solutions Extra examples (quicksort) Lab assignments Old exam papers Should be familiar with all of these Course is Algorithms and Data structures (we choose to implement them in Java – a lot of this is done in the labs) Resources

Java 2 Exam will contain some Java – either for you to interpret, or to provide (e.g. give an interface for … give a recursive method to…. ) Make sure you know Java code sufficient to define a node of SLL, DLL, BST, AVLTree, BTree But not a whole program. Likely to have seen something similar in lectures (probably identical). We use pseudocode in lectures to give a quick, implementation independent idea of an algorithm. If asked to show something in Java you can not use PC (or vice versa). Can use it to illustrate how an algorithm works (but describe it in words too if it is complicated, plus diagrams)

Outline of course 1 3 Lecture 1-2 Revision. You will have been using these concepts throughout course so will know them now. Lecture 3-4 Singly linked lists: know how to build with head, head+tail, size instance variables and be able to discuss the complexity of operations e.g. add, delete, addInOrder for each version. Know Java methods for doing these operations. Generic linked list. Lecture 5 Doubly linked lists. Use of prev and next instance variables. (The hard bit came with recursion later on!) Lecture 6 Recursion. Two rules of recursion – reduce size of data set and provide a stopping condition. Be able to write simple recursive methods in Java. Use a recursion trace to illustrate how recursion works. Linear vs. Binary recursion. When do we use binary recursion?

Outline of course 2 4 Lecture 7 Recursion on linked lists. For singly linked lists this is quite straightforward, create a new singly linked list with head = next node along. Rejoin previous list to head of this list after recursion. For doubly linked lists much harder – create a new doubly linked list with head =next node. To be a DLL have to make prev of new list =null, so remember to rejoin previous list to head of new list, AND prev of head of new list to previous list. FUNDEMENTAL PROPERTY. *

Outline of course 3 5 Lecture 8-9 Algorithm analysis (complexity). Should be able to work with O notation now. Be able to analyse a simple algorithm or program for complexity, and compare the efficiency of two algorithms. Know how the different growth rates are related (e.g. O(n) grows faster than O(log n)). Dont need to use o, or notation. Lecture 10-11 ADTs, Stacks, queues. What is an ADT? How is it implemented in Java?* Know basic interfaces for all of the ADTs we discuss in lectures (all have been given). And be able to describe implementations of them (usually an array-based and a linked list, or BST-based implementation). Stack, queue applications. Dont need Deque ADT.

Outline of course 4 6 Lecture 12-13 Lists and iterators. List ADT. Basic idea of an iterator, what it is for, and how it is used. Iterable interface. Know the basic methods within Iterator inner class. May be asked to describe how you would implement an iterator for a given implementation of an ADT, but not to provide detailed code. JCF A basic idea of what this is (you may use it in level 3!) * Lecture 14-15 Set ADT. Binary Search trees. Need to be able to define binary tree, binary search tree (whats the difference?) Traversals: preorder, inorder, postorder. Be able to define a node of a BST in Java, and simple methods (if given instance variables, and signature of method). Know how to add and delete nodes. Examples of balanced, unbalanced BSTs. Dont need expression trees.

Outline of course 5 7 Lecture 16 AVL Trees. Be able to define (i.e. what is difference between normal BST and an AVLTree?) Know how to do insertion via rotations, java to implement. Complexity of rotations*. Lecture 17 Btrees. Define m-way tree and Btree. Know how to do insertion in a Btree (see example sheets 3 and 4). Define node of Btree (need to look at code on web page). When do we use a Btree in practice (slide 12). Lecture 18-19 MergeSort and QuickSort. In each case be able to give a description of the algorithm, with examples. Proofs of: MergeSort analysis (holds in general), QuickSort, best (like MS) and worst (when subarrays of size 1 and n-1). Understand cutoff and pivot selection via median of three approach.

Outline of course 6 8 Lecture 20 -21 Maps and hash tables. Know Map ADT (but not of Entry inner class). Hash tables, when would we use one? Be able to describe a hash table (e.g. picture of bucket array). Hash functions, hash codes. Hash collision resolution (chaining, open addressing, rehashing) – be able to write a paragraph on each, plus example. Implementation of Map via hash table – know vague idea.

Download ppt "Lecture 22, Revision 1 Lecture notes Java code – CodeFromLectures folder* Example class sheets – 4 of these plus solutions Extra examples (quicksort) Lab."

Similar presentations