2013年12月6日星期五

The merge sort

I am reviewing for the knowledge we've learned this semester, and preparing for the coming final exam. Now I want to collect some useful information about the merge sort we've learned before. 

Merge sort is a recursive algorithm that continually splits a list in half. If the list is empty or has one item, it is sorted by definition (the base case). If the list has more than one item, we split the list and recursively invoke a merge sort on both halves. Once the two halves are sorted, the fundamental operation, called a merge, is performed. 

Binary Research Trees

A binary search tree relies on the property that keys that are less than the parent are found in the left subtree, and keys that are greater than the parent are found in the right subtree. To implement the binary search tree, we will use the nodes and references approach similar to the one we used to implement the linked list, and the expression tree. However, because we must be able create and work with a binary search tree that is empty, our implementation will use two classes. The first class we will call BinaryResearchTree, and the second class we will call TreeNode. 

2013年11月17日星期日

Term Test 2 Review

Last week we wrote our term test two, and I have to make a conclusion about what we've learned so far.
The most difficult part for me is the concept of "Tree" and its application. A tree include these part: node,edge,root,path,children, parent,sibling, subtree, leaf node, level and height.  A node is a fundamental part of a tree. An edge is another fundamental part of a tree. An edge connects two nodes to show that there is a relationship between them. The root is the only node in the tree that has no incoming edges. A path is an ordered list of nodes that are connected by edges. A subtree is a set of nodes and edges comprised of a parent and all the descendants of that parent.The height of a tree is equal to the maximum level of any node in the tree. And I know we must use recursion which we learn before to solve a "tree problem".
That's what I've learned so far.

2013年10月17日星期四

Why OOP and Recursion are Helpful!

OOP is short for object oriented programming. It is a kind of programming paradigm and a method of programming development.  An object is a software bundle of related state and behaviour. This programming language is useful because it uses object as a basic unit and encapsulates the data so that to improve the software more flexibility, scalability and reusability.

Recursion is a method to solve problem by breaking it into smaller subproblem until the problem is small enough to be solved easily. It is useful because it can let us write a much shorter and easier function instead of a long and difficult one when facing a complex problem.