Monday, April 4, 2016

Week 12 SLOG

I started the review process for the final exam at the beginning of week 12. I began with class design and inheritance. I realized that I had the most difficulty in choosing which common attributes should be initialized in the superclass. Practicing the questions on the past exam was very helpful in understanding concepts that are confusing. Also, def __repr__, def __str__, def visit_level, and def descendants_from_list from class Tree were very difficult to implement. Drawing example tress and tracing each example were efficient methods in finding out how each function should work. I am planning to create study sessions with friends to help each other out and exchange ideas on how to effectively prepare for this exam.

Monday, March 28, 2016

Week 11 SLOG

At this point in CSC148, I would like to reflect on how my thoughts about the topic of recursion have changed and developed from week 7. When I first learned about recursion, the idea of a function calling itself again was very interesting. I got the impression that if the solution of a smaller part of a function can be found using the same algorithm as the original problem, it is always convenient to use recursion to break up the problem into smaller pieces. Therefore, when I implemented codes for trees, binary trees and binary search trees in class, I always used recursion to simplify the problem since we only dealt with small data structures. However, while working on assignment two, the implementation of depth_first_solve and breadth_first_solve in puzzle tools changed some of my thoughts.
When I first read about Professor Heap’s guidelines for implementing these functions, I thought that keeping track of visited nodes would be an effective idea, but I also thought that the program would still run normally without any problem although it might take longer even if I did not implement this part. However, since the assignment deals with big data structures and too much repetitive data is stored in the memory, I came across a memory run-out problem. Therefore, I decided to implement visited_nodes to keep track of all of the nodes that I have already visited. However, I was still experiencing memory run-out because of the number of nodes in the data structure and numerous levels to check. I learned that it is important not only to control the total number of recursive calls but also to minimize the maximum depth of recursive calls to fix this memory run-out problem.
Through this assignment, I realized that recursion is a very useful and convenient skill, but in real life situations when the total data size is huge, time complexity and memory management are as important as the algorithm itself. As we have started to learn about time complexity in class this week, I think it will be very useful in writing more time effective programs. Also, with curiosity, I searched more about memory management and time complexity and found out there is a concept called space complexity. Space complexity is a way to measure how much storage an algorithm needs. I think I will learn more about it in advanced courses. I hope that in the future I can become a developer who can design a software with not only great coding style and algorithm, but also great time and space management.

***Note: My slog URL on the CSC148 website only redirects to my week 3 slog. The URL to my entire blog is http://mycsc148celinekim.blogspot.ca/

Monday, March 21, 2016

Week 10 SLOG

Week 10 dealt with the concept of sorting and Big-O. I had to review bubble sort, insertion sort and selection sort since I haven't studied this after learning it in CSC108. I never knew last year that sorting can be connected to asymptotic notation and running time that I learned in CSC165: Mathematical Expression and Reasoning for Computer Science. Calculations and proof on big-O, big-Omega, and big-Theta that I practiced enabled me to have a better and faster understanding in week 10 slides of CSC148. This connection made me think about the overlapping concepts of CSC148 and CSC165 and the materials of the course interact. For example, proof by cases were very similar to if, elif, and else statements in coding.

Friday, March 18, 2016

Week 9 SLOG

The biggest event of week 9 was the second term test. Since I did not do so well on my first test, I tried a different method of studying this time. I focused more on practicing the examples in the slides and doing past exams. Also, I went to office hours and discussed difficult concepts with my friends. After fully understanding the concept of binary trees, working with binary search trees was not that difficult. I also tried implementing def descendants_from_list which was one of the helper functions. It was very confusing at first because of the use of queues but this exercise later helped a lot in understanding and implementing def levelorder_visit.

Thursday, March 10, 2016

Week 8 SLOG

The focus of week 8 was implementing class Tree. The terminology explained in the lecture slides was very helpful in understanding the concept of a tree. Two confusing terms were height and depth. After drawing some pictures of trees, I could understand the difference between the two vocabulary. Many functions in this class required the application of recursion. The codes for functions such as leaf_count, height, and arity were very similar to the material and examples we learned in class last week. However, using recursion for def __str__ and def __repr__ was hard to understand at first. By tracing through the docstring examples, I could see how to apply recursion in these functions. The trickiest part in creating class Tree was implement levelorder_visit. I thought that recursion must be used to implement this function like preorder_visit and postorder_visit.  After implementing levelorder_visit using a queue, I tried to use a stack to re-implement preorder_visit and postorder_visit. By trying this out, I learned the power and helpfulness of recursion.

Friday, March 4, 2016

Week 7 SLOG

A new topic discussed in CSC148 this week was recursion. Recursion is the idea of a function calling itself again. The widely used example to explain recursion is factorials.
Since n! can be divided into n * (n-1)(n-2)(n-3)...(1) which is equal to n*(n-1)!, repeatedly calling the factorial of (n-1) can be used to calculate the factorial. Through this example, I learned that recursion is convenient to use if the solution of a smaller part of the function can be found using the same algorithm as the original problem. Two things that came to mind after learning about this concept are matryoshka (Russian nesting) dolls and the Fibonacci sequence.
The most important part that programmers need to be very cautious when using recursion is the terminating condition. A terminating condition is always needed in using recursion because that condition enables the recursive function to come to an end. Without a proper terminating condition, the recursive function call will be made infinitely. When programming, errors that are raised notify the programmers to fix the program. However, when there is an infinite loop, the program goes on and on without any errors being raised.
Recursive functions usually consist of if, elif and else blocks. One of these blocks has to be the terminating condition which does not make any recursive calls. The most difficult part to me is writing the code for the block that makes several recursive subcalls. Writing the code in order to return the combined result is still confusing. However, I am planning to get used to this by getting more practice through the additional exercises in lab 6 this weekend. Even after grasping the concept and the basic structure of recursion, it was still difficult to imagine how a function calls itself and what result that brings to the body of the function. However, the tracing exercise of lab 6 was very helpful in understanding how recursion works. By going through the step by step tracing process, I could see how and when the function max_depth is called to calculate depth of the list. 

Friday, February 26, 2016

Week 6 SLOG

The focus of the week 6 lab exercise was the relationship between loops and list comprehension. By reimplementing dot_product, matrix_vector_product and pythagorean_triples functions that were written in list comprehension, I started to understand the purpose and convenience of using list comprehension. Instead of using for and while loops to implement a certain function, list comprehension condensed the task into nearly one line even though it serves the same purpose. In addition, the new concept of using filter to filter out elements and to reduce lists was interesting. The fact that there are many builtin functions that make operations convenient is amazing.

Friday, February 12, 2016

Week 5 SLOG

Week 5 was a very hectic week with assignment 1 and term test 1. Designing the layout of assignment 1 took a pretty long time since there were many classes that work together to run the whole ride simulation program. The most time-consuming and confusing part was writing the docstring examples for each function.
Also, while studying for the term test using past tests, I realized that I still have difficulty designing a completely new class. I had a hard time understanding the purpose of each function and how it should be implemented for the entire class to work. I solved this confusion by practicing more problems and trying out examples to get used to designing classes. However I still have some confusion in differentiating when and when not to use property to redirect client access. 

Friday, February 5, 2016

Week 4 SLOG

The main concept of week 4 was linked lists. Linked lists consist of nodes that are made up of the data value and its successor next_. The common pattern in linked lists was the method of making a reference to a node, usually called current_node, to move along the entire linked list. However, the most confusing part that I had trouble with was writing the code for def _getitem_. If an item is found, then it is not necessary to move further along the list. Using a flag to keep track if the item has been found was at first very hard to grasp. When appending and prepending to the list, I constantly forgot to check self.back and self.front. In addition, using "assert" to raise an error was very confusing. However, drawing pictures to simulate the situation helped in understanding how the function works and solving the confusion.

Friday, January 29, 2016

Week 3 SLOG

The focus of the last two weeks of CSC148 was that Python is an object-oriented programming language. The basic building block of a Python-based software is objects. The way we can define an object is using class. A class is a blueprint for an object that consists of attributes and methods. Attributes characterizes the object of the class, and the methods describe the behavior of the class. The most interesting characteristic of class is “inheritance”. The subclass can inherit, override, or extend any attributes or methods of the superclass. Also, a subclass can inherit from multiple superclasses. This is advantageous in that it avoids repetition of duplicate codes and that the relationships between different classes are visible. At first, it was difficult to understand this topic but using the analogy to biology helped me clarify the ideas. Inherited methods or attributes are like the characteristics that I received from my parents, overridden methods are the common but different characteristics, and extended methods are the unique characteristics that I own independently.