I am quiet happy with my performance in CSC148 right now. It seems like I have found my ways to deal with the course. I scored around 90% in both tests, which made me so happy, and the recent subjects I learned (Tree and running time) helped me to be even more interested in Computer Science. Hope I can finally get into the major.
Tree is not a abstract concept for me. As professor usually explain Tree questions with pictures, it is easy to understand. The keys to solve the questions about Tree are paying attention to return type, base case and recursion step. Below is a function I wrote to practice.
def count_interior(t):
“””
Return the number of nodes that are not leaf in t.
“””
Acc = 0
if t.children:
Acc += 1
for child in t.children:
Acc += (count_interior(child))
return Acc
Test 2 was really helpful for applying and reviewing the knowledge I learned during past couple weeks. I read the Notes from the lecture and quiz, did some past tests and discussed some hard questions with my peers. I am pretty satisfied with the final result I got, but, meanwhile, I know I still got a lot of things need to improve. I am still not able to write the codes in the test without hesitation and some marks were deducted for some small mistakes. I think the problem is that I haven’t write enough amount of code by myself. So I am going to put more portion of my time into code writing during my revision for the final exam.
The running time is a little bit abstract for me as it asks me to imagine the steps computer goes through during the execution of code. CSC165 is also talking about running time right now, but the complicated math problem really confused me. I think I still need to practice a lot in order to be familiar with this topic. Hope doing substantial amount of questions can help me understand it quick.
Below is a question about running time that I am working on:
def inorder(t):
if not t:
return []
return (inorder(t.left) + [t.data] + inorder(t.right))
Solution:
Assume n is the size of t.
inorder visits each node once, perform constant time on each node. As a result , it takes O(n).
This is not a hard question. What I am doing is to understand how it works and to be familiar with what the answers should look like.
Thank you for spending your time to read my slog, have a nice day!
没有评论:
发表评论