Thursday, April 7, 2016

Week 12 SLOG

Hey guys,
    This week we learned about Hash Tables and Tracing code. Tracing code was fairly straight forward. However, I can't say the same about Hash Tables. I really don't understand what a Hash even is. I will definitely have to put a lot of work into learning this in fear of it taking up a large portion of the final exam due to it being one of the last things we learn. After a quick google search:
http://searchsqlserver.techtarget.com/definition/hashing
from the article: "Hashing is the transformation of a string of characters into a usually shorter fixed-length value or key that represents the original string. Hashing is used to index and retrieve items in a database because it is faster to find the item using the shorter hashed key than to find it using the original value."
This reminds me of dictionaries actually, associating a string of characters with a key and using that key to find the string of characters.
Will definitely need to do more research though.
Anyways,

-Anthony Arena

Wednesday, March 30, 2016

Week 11 SLOG

Hello everyone, for the final time.
    It has been a pleasure writing these SLOGs and it was an interesting experience. Going back and reading through my SLOG was actually the best part of having a blog! What is quite apparent is how I seemed to begin to "get it" as the course went on. I still remember the first lecture I attended for CSC148... It hit me like a truck(I am putting this nicely). I had no idea what was going on, I felt extremely unprepared and I felt like everyone in the class had a massive advantage over me. The first lab was surprising, it really showed how LITTLE I knew of classes. I could not even finish half of the lab in the time we were given, and I received a 1/2 on the first quiz. I was frustrated. I finished the entire first lab on my own time after the lab session and I went to upper year students for help. They assisted me in understanding what a class really was, and what __init__, __str__, and __eq__ actually were. Things started looking much better for me after this. I decided to start writing the programs for lab in advance so that I could use my lab time for asking questions, or if I had no questions...... I would read reddit :). I started becoming more and more interested in programming as the course went on. To my surprise, I feel as if I have learned more valuable information in CSC148 than in any other course I have ever taken in my life, aside from maybe Multi Variable Calculus and Partial Differential Equations. I believe that an essential piece of the make-a-course-interesting-puzzle is to have charismatic instructors and TA's who can really get on the students level and help them out, and I was lucky enough to have a great TA. My TA, Brian, was always loud, fun and really grabbed your attention. He would never just give me the answers, but would tell me the general direction I should be looking in, which helped me learn how to see the problems in my code. I feel that this is what ALL TA's should do, not just in computer science, but in all disciplines.
    The earlier entry I would like to revisit is actually the entry where I wrote about my favorite topic of this course: Recursion. Aside from learning about the basics of what a class is and how they are useful, I feel as if recursion is one of the most key concepts we learned. I also learned that tracing recursion can be a bit of a hassle, but it really tests your tracing abilities. I would actually like to talk about how I used recursion with trees in one of the labs, but first, let me show you the code:

def arity(t):
    """
    Return the maximum branching factor (arity) of Tree t.

    @param Tree t: tree to find the arity of
    @rtype: int

    >>> t = Tree(23)
    >>> arity(t)
    0
    >>> tn2 = Tree(2, [Tree(4), Tree(4.5), Tree(5), Tree(5.75)])
    >>> tn3 = Tree(3, [Tree(6), Tree(7)])
    >>> tn1 = Tree(1, [tn2, tn3])
    >>> arity(tn1)
    4
    """
    if len(t.children) == 0:
        return 0
    else:
        c = len(t.children)
        for i in t.children:
            c = max(c, arity(i))
        return c

I know that this implementation of recursion is easy to do, but that is where the beauty of recursion lies. The beauty of recursion is in it's seeming simplicity. Using it, you can write what would normally be an ugly code full of loops in just a few simple lines. Checking a base case, followed by recurring. It can be hard to really appreciate what you are learning until you look back at what you have learned and see it in retrospect. When I first learned of recursion it was immediately obvious that it had great implications, but I couldn't appreciate those implications until I spent time actually using recursion and see how much shorter and easier it made some things.
    Anyways, I am glad I made this blog. It was insightful, and to anyone who is reading this; I hope you learned something from my blog!

-Anthony Arena

Tuesday, March 29, 2016

Week 10 SLOG

Hi everyone.
This week we learned about efficiency. Pretty straight forward concepts. I took CSC165 back in first year so this information was covered at one point in my life, so re learning it was no issue. Not much to say here really.

-Anthony Arena

Monday, March 28, 2016

Week 9 SLOG

Hello,
Week 9 is very closely related to week 8. Essentially, we are just learning more about Trees. We talked about deleting data from a BST and inserting data. We went over the algorithm for delete in class. I decided to learn this material before going over it on my Wednesday night lecture by doing the lab ahead of time. Overall it was straight forward. The lab quiz was straight forward as well, however I was lacking sleep the day of the quiz due to having other work to do the previous night. I wrote the quiz slower than usual, but I did fine on the quiz in the end.

-Anthony Arena

Week 8 SLOG

Hey guys. Today I will talk about my experience learning binary trees, which is what we learned in week 8 of CSC148.
I found binary trees fairly easy to understand. I believe this is because they reminded me of a linked list. One node points to multiple other nodes. Binary trees seemed to be just an extension of linked lists, however when writing the methods for the BT(Binary Tree) in lab, we used recursion, which we didn't do when doing linked lists(partially because the majority of the class did not know what recursion was at that time in the course). Most difficult thing to remember about binary trees is visiting the trees inorder, preorder and postorder and remembering the differences.
Until next time,

-Anthony Arena

Wednesday, March 2, 2016

Week 7 SLOG

Hello everyone,
    I would like to talk more about recursion in this SLOG. Thinking more about the quiz on recursion from last week, I tried to recall what I wrote on the quiz and run it through python to see if it would work, and if what I wrote on the quiz is what I think I wrote on the quiz, then I found that it works! This is what I believe I wrote:

def count_characters(string_list):
    """Returns the total number of characters in a list.

    @type string_list: list | str
    @rtype: int
    """
    if isinstance(string_list, list):
        n = 0
        for i in string_list:
            n += count_characters(i)
        return n
    else:
        return len(string_list)

Well, I hope that is what I wrote...

    Anyways, I did some research on recursion and what I found got me quite interested in recursion. In point form, I found that:
-Problems that can be solved with recursion can usually be solved with loops.
-Loops can sometimes be a more efficient that recursion.
-Recursive functions take up more memory and resources than a loop.
These may all seem like reasons to not use recursion, but what is interesting is that recursion is also usually faster and easier to code than a loop, and you can get the same results as a loop. While reading about recursion, I also found a good way to think about recursive functions. They usually follow two rules:

1. If the problem can be solved simply without recursion, return a value
2. If the problem cannot be solved simply without recursion, reduce the size of the problem and call the recursive function inside the smaller problem.

If we look at the code I wrote earlier, that is exactly what I had done. If string_list is a list, I reduce the problem and call recursion until to solve the problem I don't need recursion. If string_list is not a list, I return a value, len(string_list). It is quite simple actually!

-Anthony Arena

Week 6 SLOG

"Hello everybody, here we are again" - Professor Daniel James
^ You will laugh if you took PHY151 with Professor James..........
Anyways, in week 6 we covered recursion in lecture(though I didn't attend the lecture..). I read the lecture slides on recursion quickly before lab and I actually thought recursion wasn't so hard to understand. I think I did well on the quiz at the end of the lab on recursion. I had no time to actually do any code that had to do with recursion because I was pretty busy with a few other courses midterms, problem sets and lab reports, so whatever I did on the quiz was the first time I actually wrote any recursive code. I will most likely try and put some time into playing with recursion this weekend and getting more comfortable with it.

-Anthony Arena