CS241: Spring 2017 -- Lecture 19, software development, nary tree

  1. Writing BinaryTree
    As always
    1. representation: either empty, or, root, right, & left
    2. operations -- write these first:
      1. constructors
      2. accessors
      3. isEmpty()
      4. toString - plain & recursive
    3. Testing before use!!
  2. heap questions?
  3. n-ary trees
  4. Groups! Prototype a game tree generator for a very simple game:
    1. A ridiculous game: Two players, a pile of tokens, on your turn you may take either 1 or 2 -- whoever gets the last one loses.
    2. Assume you have a Board class (that contains the current state of the game, i.e. how many tokens are left and whose turn it is). Assume it has these methods:
      1. boolean gameOver()
      2. BoardList generateNextLegalBoards()
    3. Write and test an NaryTree class with
      1. NaryTree(Board) constructor (which stores the Board as the root)
      2. addKids() method (which recursively builds the entire tree from this root)
      3. public String toString() that outputs the tree textually (assume Board has toString())
    4. Tell me/demo when you are done!