Algorithms

Spring 2017
course
navigation

Mar 27

I will look over midterm projects and we'll discuss then. Comments/questions now?
Discuss the upcoming schedule for assignments. Move to a Tuesday due date?

trees

This week: look at the discussion in the text of trees - heaps in particular.
I would like to pick up the pace a bit, and do this chapter in about 1 week now that I think you are familiar with the general ideas behind what we're doing.
A tree is a special case of a graph - which we'll do next.
Please read the chapter in the textbook on trees, making sure you understand
We'll walk through some of the text today in class.
Topics :
I have several issues with their tree discussion
In the section using classes, the "else" is still not needed :
def insertLeft(self, newNodeName): oldLeft = self.leftChild self.LeftChild = BinaryTree(newNodeName) self.leftChild.leftChild = oldLeft
Also, they don't create any good tools for displaying these trees.
See http://en.wikipedia.org/wiki/Tree_traversal for a clearer explanation of the traversal stuff. In particular, all of these are part of a "depth-first" traversal, and depending on what you want to do, there may be pre-, in-, and post- operations.
They have left breadth & depth traversals until the graph section ... which seems like a funny choice to me.

aside : graphviz

A cool command line tool for generating graphs from a text (.dot) file : http://cs.marlboro.edu/on-campus/graphviz/dot.cgi
Here's an example :
graph foo { 2 -- {3 5}; 3 -- {e[label=8] 10}; 5 -- {12 8}; e -- 9; }
where the "e" node displays as "8" but is a different node than 8.
http://cs.marlboro.edu/ courses/ spring2017/algorithms/ notes/ Mar_27
last modified Monday March 27 2017 8:40 pm EDT