Module 2
Trees
Pseudocode


CC315

Attributes

  • Item
  • Parent
  • Children

Example

Node parent children item
A None {B, C} A
B A {} B
C A {D, E} C
D C {} D
E C {} E
F None {} F

Initialization


    MyTree foo = MyTree('13')
 

Getters

  • getItem
    returns the item
  • getParent
    returns the parent
  • getChildren
    returns the children

Basic Functions

  • isRoot
    returns true if this is the root
  • isLeaf
    returns true if this is a leaf

Basic Functions

  • getDegree
    returns the degree of this node
  • findChild(value)
    returns the child with the input value