Text
Week  8 Slog
This week we first reviewed the material from last week about tree, we reviewed the terminology involved and also learned about binary trees and binary search treesÂ
Binary trees are the trees that only have two arity (branches), the children of a node t in the tree would be represented by t.left and t.right. Then we talked about the orders, how the system read the binary trees, what orders do they use - inorder; preorder; postorderÂ
in order: root.left -> act(root) -> root.rightÂ
0 notes
Text
Week 7 Slog
Last week we learned about recursive functions. For this week, we reviewed things from last week and learned to trace recursive functions using stacks. Prof used two functions as examples: Factorial function and Fibonacci function.
Factorial function is basically using the function representation of  Factorial(n) = n * Factorial(n-1)
Fibonacci function uses the representation of Fib(n) = Fib(n-1) + Fib(n-2)
Two most basic elements of a recursion function are base case and recursive case. Base cases act like stoppers of a recursion function: they are defined as a certain value; recursive functions are the recursive part, containing the name of the function, repeated. For instance, Base cases: Fibonacci(1) = 1 and Fibonacci(0) = 1, whereas Fibonacci(n-1) and Fibonacci(n-2) are recursive cases
A recursive function has at least one base case and at least one recursive caseÂ
To write base cases and recursive cases: use if to define the range and the value that is given to such range; else would return the function for the rest of x in the function
Stacks have an important  characteristic: activation record: all information necessary for tracing a method call, such as parameters, local variables, return address, etc. When a method is called, activation record is created, initialized, and pushed onto the stack When a method finishes, its activation record (that is on top of the stack) is popped from the stack
0 notes
Text
Week 6 Slog
Week 6 Slog
We learned about recursion function in Wednesday’s lecture. One way to determine if the function is recursion function is to check the body function, if the name of the function in the body function at least once. Also that recursion function can be rewrite into loop functions.
For a function such as sum_list (L): L can be a list, or a integer. If L is a integer, then the output of the function simply return L itself; if L is a list, according to the description of the function, we are going to apply the function of sum_list to all the units in L. So that in the second scenario, when L is a list, we are going to make for every unit x in the list L going through the function – sum_list(x) for x in L. Then we need to return the sum of the new lust we get: return sum([sum_list(x) for x in L]).
Lc
0 notes
Text
Week 4 SLOG
Week 4 SLOG
Today we first learned about the difference between sack and stack. A stack contains items of carious sorts, and the new items are added onto the top of the stack. A sack contains items of various sorts, and the new items are added onto a random place in the sack. The order of a sack is unpredictable. For both containers, if the list is empty, it would produce a mistake if trying to remove an item.
Then we talked about the methods should be used to for implement, also the ones to be implemented by subclasses. And after class discussion, we found that this could be grouped in many ways. However there is a general rule that for sacks, __eq__() cannot be used since that the sacks are equal; for the location of item 1 in bag 1 is not necessarily the item 2 in bag 2
0 notes
Text
Helloooooo World
20160127 Week 3Â
Today I summarized the lecture material from week 1 and week 2 and found I had so many questions loll And probably all of them are stupid. Also I’m still kind of nervous about the tomorrow’s quiz, I was so lost in today’s lecture. Today’s lecture prof talked about many philosophical concepts, such as the relationship between objects and their active agents. For instance, the action of dial comparing to phone is an active agent, whereas the phone that is used for dialing is the object. Also from today’s lecture I’ve also learned that when defining a class some of its features are “has” (component of that object), and some are the active agents of it, and that is two concepts we need to distinguish from each other.
2 notes
·
View notes