Friday, 6 March 2015

Tree

      The topic of tree has been discussed recently in class, so I summarized some general characteristics of different types of trees we have learned so far.
      We've learned different types of data structures such as linear data structures stack and array to store information in computer. Tree is a logical model in python, it is a recursive date structure used to represent hierarchical data. The node on the top of the tree is called the root, each node can contain any type of data, or sometimes a link or a reference to other nodes called children.
      A binary tree is a common tree having an important property that each node of a binary tree is able to have at most two children: left child and right child.
      Moreover, a binary search tree is an ordered binary tree that its left subtree of a node contains only nodes with keys less that the node's key while its right subtree of a node contains only nodes with keys greater than the node's key, for both the left and right subtrees are also binary search trees.

Saturday, 28 February 2015

Abstract Data Types(ADTs)


 A few weeks ago, the concept of abstract data types (ADTs) was introduced in CSC148. An abstract data type is basically a way of storing information and organizing that information. It is defined in terms of its data items and associated operations, but not its actual implementation details, in which case the abstract methods indicates ‘what’ they do instead of ‘how’ they do.

Stack and queue are two examples of ADTs. The structure of stack can be described by the term ‘last in first out’ (LIFO), which means that whatever the last thing we add to the stack is the first thing that will come out of the stack. In this case, tray dispenser is an example. Either if we want to add a tray or remove a tray, the operation always occurs on the top of the tray dispenser. The normal operations associated with stack are ‘push’, ‘pop’,  ‘top’, and ‘is_empty’. The operations ‘push’ and ‘pop’ allows us add and remove items in the stack, ‘top’ helps us examine whatever the top item is, and ‘is_empty’ indicates whether the stack is empty. Items have no index. 
    In a queue data structure, elements are sorted by insertion order, referring to the term ‘last in last out’ (FIFO). For instance, the way queue works is similar to the line at the cash register. People line up one after another, but the first person that will be served will be the one whom came first. It only allows us to add to the back and remove from front, associating with two operations of queue: ‘enqueue’ and ‘dequeue’. Notice that middle elements cannot be accessed directly.

Saturday, 31 January 2015

Recursion

    During this week, I got some fresh ideas about recursion, which is an essential tool used in computer science basically when a function calls itself. At first, I didn’t figure it out completely because the technique used in the function seemed that there was no big difference between the functions we learned previously and this new recursion function. However, when I ran and called functions in shell I became confused about the result came out. Tracing functions helps me understand how the recursive functions behave. Since we are calling the same function again and again, it is easy to make mistakes, therefore, it is important to trace it step by step logically. When we are tracing the recursive functions, we will eventually get to the base case when problems are progressively getting smaller and smaller. All the problems will become easier when you can fully understand the process of tracing recursive functions.

Thursday, 22 January 2015

Why geeks should write

    Computer science requires strong logical thinking skills. The ability to convey ideas in written English is one of the important elements to help think logically. In this case, writing serves multiple purposes.
    First, when geeks are confused or uninspired, writing is a perfect way to help freshen their mind and clarify their thoughts. Keeping a log gives a record, so that we will be clear about what has already done and what to do next. In this case, the record also offers us some experience that we can review and refer to if we need to go through a similar situation again in the future. Meanwhile, the record offers assistance to other programmers to understand our code. Therefore saves time to rewrite when they want to use it.
    Moreover, our mind palace sometimes ignores some tiny details that may actually be very important during our programming process. By writing down either our goals or our problems, we get a chance to reanalyze all the information clearly with everything listed including our blind spots. If a person can write the journal fluently and logically, then he will be able to organize and communicate the ideas because he gets better understanding of what he is working on.