# MIDTERM 2

## SAMPLE FORMAT

Here is the sample format for the exam. Please read through the instructions and familiarize yourself with the format.

You are responsible for material covered in:

• Lectures
• Readings: Recursion, Searching, Trees, Binary-Search-Trees, Red-Black Trees, Graphs, Hashing and Sorting.
• Homeworks: 4 through 6 and extra credit (solutions posted on Learn@UW)
• Program: 2 and 3

## Topics

• Recursion
recursive methods, base case, recursion rules, how method calls work (i.e., activation records and the call stack), recursion vs. iteration, recursive data structures, analyzing complexity of recursive methods, recurrence equations, determining complexity using recurrence relations
• Search
Comparable interface, sequential search, binary search, complexities of search algorithms
• Trees
position-oriented vs. value-oriented ADTs, tree terminology (root, leaf, node, edge, parent, child, sibling, ancestor, descendant, subtree, path, length of a path, height of a tree, full tree, complete tree, height-balanced tree), general trees, binary trees, implementation of trees, writing recursive methods that traverse a tree, pre-order traversal, post-order traversal, level-order traversal, in-order traversal
• Binary Search Trees
binary search trees (BSTs), key value, implementing BSTs, algorithms for BST operations (print, lookup, insert, delete), in-order successor, in-order predecessor, complexities of BST operations
• Red-Black Trees
balanced search trees, red-black trees, red-black tree properties, root property, red property, black property, algorithms for red-black tree operations (print, lookup, insert)
• Graphs
graph terminology: node, vertex, edge, directed, undirected, source, target, adjacent, successor, predecessor, degree, in-degree, out-degree, path; classifying different kinds of graphs: cyclic, acyclic, complete, connected, weakly-/strongly-connected, connected component, weighted, DAG; graph ADT (implementations & complexities), representing edges: adjacency lists, adjacency matrix; graph traversals (BFS & DFS), spanning trees, finding paths & cycles, Dijkstra's algorithm, topological ordering
• Hashing
hashing terminology: key, hash function, hash code/index, hash table, load factor, collision, ideal hashing; hash table operations (algorithms & complexities); choosing table size; defining a good hash function, hashing techniques: mod by table size, folding, extraction, weighting, handling non-integer keys; collision handling strategies: open addressing (linear & quadratic probing, double hashing) and buckets (using different data structures)
• Sorting
comparison sorts: (algorithms & complexities - time & space, best & worst case circumstances) including bubble sort, insertion sort, selection sort, merge sort, quick sort, heap sort; stable sort, radix sort