CS241: Spring 2017 -- Lecture 20, software development, nary tree
- Writing Heap
As always
- Select a representation: array and insertion point index
- operations -- write these first:
- constructor(s)
- accessors
- isEmpty()
- toString
- Testing before use!!
- n-ary trees
- definition - has a root and n subtrees (each an n-ary tree)
- thus, may be implemented as a root and a list of n-ary trees (its children)
- as a representation for a game tree --
The root of the tree is the beginning (or current) situation in the game.
The children of the root are all the possible positions after one move.
- Prototype game tree generator:
- tic tac toe.
- Assume you have a Board class (that contains the current state of the game, i.e. where there are x's and o's and whose turn it is). Assume it has these methods:
boolean gameOver()
BoardList generateNextLegalBoards()
- An NaryTree class with
NaryTree(Board)
constructor (which stores the Board as the root)
addKids()
method (which recursively builds the entire tree from this root)
public String toString()
that outputs the tree textually (assume Board has toString())
- Areas in computing
- Programming - learning to write programs (i.e. convert algorithms to code)
- Systems -- code that allows you to accomplish things
- Compilers - convert source code to executable code
- Operating systems - lowest level interface to hardware. Run apps.
- Networking - communication
- Databases - store info
- Computing as a tool for other fields
- A bit about bioinformatics
- Tech, nanotech, and biotech
- "All life on this planet is one thing"; or at least, has a common ancestor -- panspermia?
- DNA is the instructions for building organisms
- Can infer which organisms descended from which, and how long ago they split off by
looking at/computing similarities between their DNA (the code is A, T, G, and C). What causes changes?
- Deletion
- Insertion
- Mutation
- Etc... but this is more than we will take on here
- Instead we will implement a simple bioinformatics algorithm
as our last lab