SE250:lab-7:hals016

From Marks Wiki
Jump to navigation Jump to search

Lab 7

Lab 7 has to be opened by using the Cygwin Bash shell cmd.

Movement

To move around the tree the commands "left", "right" and "parent" can be used. The star moves down the tree left and right correspondingly to the commands. However the parent function just goes to the root which suggests its not properly implemented. If the star (navigator) gets lost/broken, the command "root" will take you back to the root.

Perfectly balanced, 7 inputs a-g

    a
  b
    c
d (*)
    e
  f
    g

Made using insert functions (ie, i 4). Any other insertion orders will not work but in terms of the order of insertion, as long as d is the root and b and f are the left and right trees then it will be the same (perfectly)

Order confirmation

Skewing and then rotating left will have the same order when the order is recorded before the rotate left and after as well. ie, the print function was used to see the order.

    a
  b
    c
d (*)
    e
  f
    g
> skew
a (*)
  b
    c
      d
        e
          f
            g
> print
Tree[*a*,b,c,d,e,f,g] //Order 1
> rotate left
  a (*)
b
  c
    d
      e
        f
          g
> print
Tree[*a*,b,c,d,e,f,g] //Order 2 (same as order 1)