CS241: Topics for the Week of November 5, 2007
[previous][next]
-  Reading:  Chp 10, Chapter 11, Section 3
 -  Monday - go  over Lab 8: Recursion and Divide-and-Conquer Sorting
 -  Discuss new lab: Lab 9: Trees
 -  Quicksort - divide and conquer (recursive algorithm) 
-  sorts in place
 -  can move elements long distance in single swap
 -  Θ(n log n) on average, Θ(n2) worst case
 -  See code in textbook on pp. 240 and 242.
 -  Smart ways of picking the pivot can speed algorithm and reduce likelihood of worst case situation.
 
 -  Trees
-   The Tree Data Structure
 -  Tree Abstract Data Type: defined by operations root(), children(), parent().  Other operations
    could be height(), find(), insert(), isLeaf(), isRoot(), isInternal(),...
 -  Binary Tree Abstract Data Type: operations include above plus getLeft(), getRight();
 -  Binary Search Tree Abstract Data Type: insert(), find(), contains(), remove(),  successor(), getLargest(), getSmallest(), height(), traverse() - various kinds, 
 -  Terminology: 
root, children, leaf node, internal node, level, depth, degenerate tree, (proper) descendants, (proper) ancestors, siblings,height, full tree, perfect tree, binary tree, binary search  tree, subtree.
 -  Binary Trees  and Binary Search Trees
 -  Binary Tree Traversal: 
-  pre-order, post-order, in-order
 -  level order
 -  depth-first vs
    breadth first
 
 - What is complexity of above operations for a tree? What if the tree is balanced? 
 -  Deleting items from a binary search tree
 -  Given a complete binary tree of height h, how many nodes are there?  How many nodes are in the last level (the leaf nodes)?
 -  Balanced trees: Red Black Trees
 -  Storing a set of comparable items. Compare the complexity of various operations (find, insert, remove)
for the following data tpes:
-  unsorted list (array vs linked)
 -  sorted list (array vs linked)
 -  tree, balanced tree
 -  hash table (to be covered later)
 
 
 -  Tree Applications
-  Solving Sudoku
 -  Mazes
 -  MiniMax Game Trees 
-  Works for two player games with perfect information. Each level (or ply) corresponds to the choices of 
one of the players at a particular turn. Assumes player play to the best of their ability.
 -  TicTacToe: see text, and Game tree
 -  Game of Nim: Game Tree, MatchSticks, Coins
 
 
 
[top]  [Schedule] 
[Home]