Reading week is over and Assignment 2 is up with the deadline fast
approaching!!! I haven’t posted anything on week 6 because I was busy with
studying for my other midterms, along with fixing some ‘last-minute’ errors in
my Assignment 1. On the other hand, reading week was a great relaxer for me
although it was too short! I am disappointed in myself because I planned how I
would spend my reading week productively, but in the end, I did not do ANY
work, when I should have started working on my Assignment 2. Additionally, the
first CSC148 midterm occurred this week Wednesday (February 26, 2014). I must
say the exam was quite easy although I did make a few mistakes in one/two of
the questions, which I hope doesn’t cost me a lot of marks. Anyways, in the end
of last week and this week’s lecture we examined a new concept of recursion in
Python…that is Trees.
A Tree is a class – it has its own parameters and methods or functions. A Tree
is used to store data in Python, and its structure is like real tree that is
linked by nodes, which can have zero or more ‘children’ and at most one
‘parent’. Some terms to be familiar with when dealing with Trees in Python are
root, leaves, internal nodes, subtree and forest. More than one trees in Python
is called a FOREST (LOL), and a subtree is a portion of a Tree structure.
Internal nodes are just as the name says…nodes that are ‘inside’ a tree, and
has children, so they are not leaves or a root. Leaves are the nodes at the
bottom level of a Tree, while a root is the node at the top of a Tree (which is
the opposite of a real tree). Having these terms/names helps me remember its
features by relating it to a real tree.
I have noticed that recursion plays a major role in Trees. Trees have
some main functions like height, which is the maximum or longest path from some
node to a leaf, and depth, which is the length of the path of a node to its
root. Also, the main method used to analyze a Tree is called traversal, which
comprises of preorder, inorder & postorder. For more information on each
traversal method, see the link below, which someone brilliantly shared on
Piazza (the course ‘forum’ website).
http://www.youtube.com/watch?v=83qfcisjol4&feature=youtu.be
No comments:
Post a Comment