Currently, week 5 of class is in progress, and I have had both my lectures already. My tutorial is tomorrow so I'll be posting an update on that by Saturday.
For those that don't know, I have two (1 hour) lectures and a two hour tutorial per week. In the future I'm planning on putting up a blog post directly after my first lecture, and a second post for the second lecture and tutorial.
Jumping into the content now:
For my first lecture of the week, was primarily dedicated to information/help for the first assignment. By the point this lecture was given I had completed said assignment. As such I payed almost no attention to the lecture. The majority of the questions seemed to be directed towards creating the required recursive functions.
For the second lecture of the week, after the first assignment was due, recursive structures were covered. It was opened with a look at various recursive objects in nature (such as broccoli.) Following that we covered some terminology, which I don't remember the exact terms but if I saw them I would know them (you know what I mean.) After that we moved to tree diagrams (of the binary type) and covered pre-order, in-order, and post-order.
| Fig. 1 Sierpinski's Triangle |
In programming, when you have a recursive object the standard way to deal with it is by using recursive functions.
In general, Recursive programming is a very useful tool for programmers as it allows them to repeat the same series of actions over and over without using a loop. It is also a very "human" way to look at problems, using the idea that if X solves one problem of type Y, then X will solve any number of Y-type problems.
As an example of this, let us take a look at a Binary Tree.
| Fig. 2 Binary Tree |
A binary tree is a recursive object by the principle that the whole tree can be subdivided into smaller and smaller trees.
A Binary Tree is composed of a Nodes and Edges.
A node is one of the circular objects containing any value, be it a Str, int, or Object.
An edge is a line connecting two nodes together.
A node is a Parent Node if it has an edge that points to a lower node in the tree. Conversely, a Child Node is one that has a parent.
Note that a node can both be a child and a parent.
Each node in the tree will have exactly one parent node. The node without a parent is know as the Root.
Since writing this out in paragraph form is becoming messy, I will just give the term and definition forthwith.
Terminology:
Leaf: a node with no (None Type) children
Internal Node: A node that is not a leaf node (includes root node)
Subtree: any tree formed within the larger macro structure tree
Height: Length of the longest path of edges in the tree
Arity, Branching factor: The maximum number of children any single node can have.
Note that a binary tree has an arity of 2 (hence the term binary)
In-Order: pre-order to left subtree, the root, then pre-order right subtree
Pre-Order: Root, in-order left subtree, in-order right subtree
Post-Order: Post-order left, post-order right, root
I will upload the code for each of these, and the binary tree list later. I don't have them on me at this time, and don't particularly feel like thinking about them again.
No comments:
Post a Comment